我已经创建了一个Windows WCF服务并为其生成了WSDL。我正在使用基本的http绑定。当我尝试从IOS调用它(使用生成的basicHttpBinding wsdl2objc类)时,我在调用其中一个WCF方法时出错。错误(来自logXMLInOut)表明问题是由于地址不匹配造成的,但是我不知道如何调试这个和\或我做错了。
以下是完整的错误消息:
2011-06-10 11:54:05.534 IpadWebServiceTest[10149:207] OutputHeaders:
{
"Content-Length" = 462;
"Content-Type" = "application/soap+xml; charset=utf-8";
Host = "192.168.1.69";
Soapaction = "FredIannon.TestService/IHelloIndigoService/FredContractNoParm";
"User-Agent" = wsdl2objc;
}
2011-06-10 11:54:05.536 IpadWebServiceTest[10149:207] OutputBody:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:HelloIndigoService="FredIannon.TestService" xmlns:tns1="http://schemas.microsoft.com/2003/10/Serialization/" xsl:version="1.0">
<soap:Body>
<HelloIndigoService:FredContractNoParm/>
</soap:Body>
</soap:Envelope>
2011-06-10 11:54:05.589 IpadWebServiceTest[10149:207] ResponseStatus: 500
2011-06-10 11:54:05.590 IpadWebServiceTest[10149:207] ResponseHeaders:
{
"Content-Length" = 615;
"Content-Type" = "application/soap+xml; charset=utf-8";
Date = "Fri, 10 Jun 2011 16:54:05 GMT";
Server = "Microsoft-HTTPAPI/2.0";
}
2011-06-10 11:54:05.591 IpadWebServiceTest[10149:207] ResponseBody:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action></s:Header><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value>a:DestinationUnreachable</s:Value></s:Subcode></s:Code><s:Reason><s:Text xml:lang="en-US">The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
这是主机app.config
<services>
<service
behaviorConfiguration="serviceBehavior"
name="HelloIndigo.HelloIndigoService">
<endpoint address="HelloIndigoService"
binding="basicHttpBinding"
bindingNamespace="FredIannon.TestService"
name="basicHttp"
contract="HelloIndigo.IHelloIndigoService" />
<endpoint binding="mexHttpBinding"
name="mex"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://192.168.1.69:8000/HelloIndigo/HelloIndigoService" />
<!-- <add baseAddress="http://localhost:8000/HelloIndigo/HelloIndigoService" /> -->
</baseAddresses>
</host>
</service>
</services>
答案 0 :(得分:2)
WCF服务正在接收您的soap,但它无法正确解析wsdl2objc代理生成的soap标头。这篇文章有一个你遇到的good description of the actual problem。要确定所需的标头是什么,首先要创建一个成功调用该服务的.NET WCF客户端。通过捕获它发送的肥皂来查看预期的标题应该是什么。修改代理代码以生成精确的soap标头作为.NET客户端。