更新
我已经发布了由 java WCF 客户端生成的肥皂。WCF 工作正常。还发布了来自用于生成两个客户端的 WSDL 方法的消息模式。java 客户端的一个潜在用途是它看起来应该为外部数组使用 ArrayOfArrayOfRequestParameter 而不是 ArrayOfRequestParameter。
客户端由似乎运行 wsimport 实用程序的 eclispe 生成。在java端,我可以看到参数requests在requests[0]和requests[1]中都有2个元素,但是服务器在requests[0]中得到一个空数组,在requests[1]中得到2个元素。我猜这与数组边界的解释方式有关——也许我可以在 WCF 数据合同中设置一些属性?
该方法的签名如下:
[OperationContract]
Response[] SendMultiPartRequest(string serviceName, RequestParameter[][] requests);
这是 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; }
}
}
这是网络服务配置
<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>
这是java客户端生成的soap请求:
<?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>
这是适用于服务器的 WCF 客户端的肥皂。
<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>
这是定义函数消息的 wsdl 片段
<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>