Java client to WCF web service - first element of 2d arrray parameter is dropped

926 Views Asked by At

Update

I have posted soap generated by java WCF clients. The WCF one works fine. Have also posted the schema of the message for the method from the WSDL that was used to generate both clients. One potential isuse with the java client is that it looks like it should have ArrayOfArrayOfRequestParameter for the outer array instead of ArrayOfRequestParameter.

The client is generated by eclispe which seems to run the wsimport utility. On the java side I can see that the parameter requests has 2 elements in both requests[0] and requests[1] but the server get an empty array in requests[0] and 2 elements in requests[1]. Am guessing this is something to do with how array bounds are interpreted - maybe there is some attribute I can set in the WCF data contract?

The signature of the method is as follows:

[OperationContract]
Response[] SendMultiPartRequest(string serviceName, RequestParameter[][] requests);

Here is the data contract for RequestParameter:

[DataContract]
public class RequestParameter
{
    private string _key;
    private string _value;

    public RequestParameter()
    {
    }

    [DataMember]
    public string Key
    {
        get { return _key; }
        set { _key = value; }
    }

    [DataMember]
    public string Value
    {
        get { return _value; }
        set { _value = value; }
    }
}

Here is web service config

<services>
  <service behaviorConfiguration="FooServiceBehaviour" name="FooService.WebService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicConfig" contract="FooService.IFooService"
        bindingNamespace="http://foo.com/FooService"
    />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:10000/FooService"/>
      </baseAddresses>
    </host>
  </service>
</services>

<bindings>
   <basicHttpBinding>
      <binding name="basicConfig" useDefaultWebProxy="true" 
         maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      </binding>
   </basicHttpBinding>
</bindings>

<!-- For debugging purposes set the includeExceptionDetailInFaults attribute to true -->
<behaviors>
  <serviceBehaviors>
    <behavior name="FooServiceBehaviour">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="True"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

Here is the soap request generated by the java client:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
  <SendMultiPartRequest xmlns="http://foo.com/FooService">
    <serviceName>uploadTrade</serviceName>
      <requests>
        <ArrayOfRequestParameter>
            <ArrayOfRequestParameter>
                <Key>a</Key>
                <Value>100</Value>
            </ArrayOfRequestParameter>
            <ArrayOfRequestParameter>
                <Key>b</Key>
                <Value>200</Value>
            </ArrayOfRequestParameter>
        </ArrayOfRequestParameter>
        <ArrayOfRequestParameter>
            <RequestParameter>
                <Key>a</Key>
                <Value>100</Value>
            </RequestParameter>
            <RequestParameter>
                <Key>b</Key>
                <Value>200</Value>
            </RequestParameter>
        </ArrayOfRequestParameter>
    </requests>
  </SendMultiPartRequest>
</soapenv:Body>
</soapenv:Envelope>

Here is the soap for a WCF client which works fine with the server.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
    <SendMultiPartRequest xmlns="http://foo.com/FooService">
    <serviceName>service1</serviceName>
    <requests xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <ArrayOfRequestParameter>
        <RequestParameter>
            <Key>a</Key>
            <Value>100</Value>
        </RequestParameter>
        <RequestParameter>
            <Key>b</Key>
            <Value>200</Value>
        </RequestParameter>
    </ArrayOfRequestParameter>
    <ArrayOfRequestParameter>
        <RequestParameter>
            <Key>a</Key>
            <Value>100</Value>
        </RequestParameter>
        <RequestParameter>
            <Key>b</Key>
            <Value>200</Value>
        </RequestParameter>
    </ArrayOfRequestParameter>
</requests>
</SendMultiPartRequest>
</s:Body>
</s:Envelope>

Here is a fragment of wsdl that defines the message for the function

<element name="SendMultiPartRequest">
    <complexType>
        <sequence>
            <element minOccurs="0" name="serviceName" nillable="true" type="xs:string"/>
            <element minOccurs="0" name="requests" nillable="true" type="tns:ArrayOfArrayOfRequestParameter"/>
        </sequence>
    </complexType>
</element>
0

There are 0 best solutions below