2013-06-24 68 views
0

美好的一天,我正在使用基于WCF客户端构建在Apache轴上的soap 1.1服务。问题是,错误和正常的响应都不是通过内置的WCF去稠化器来分析的,而且当通过wcf客户端调用web操作时,我得到了与XML解析相关的异常。当我检查的消息,我得到这个:无法解析SOAP 1.1消息wcf客户端

<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"> 
    <s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" /> 
    <soapenv:Body> 
    <V2Response xmlns="urn:ETS"> 
     <V2Return xsi:type="ns1:TResponse" xmlns:ns1="urn:ETS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
     <fulfilmentRef></fulfilmentRef> 
     <paymentRef></paymentRef> 
     <statusCode>2013</statusCode> 
     <statusDescription>ePayments: Invalid client password specified in request.</statusDescription> 
     <transactionId xsi:nil="true" /> 
     <transactionTimeStamp>2013-06-21T08:22:16.483Z</transactionTimeStamp> 
     </V2Return> 
    </V2Response> 
    </soapenv:Body> 
</soapenv:Envelope> 

这我得到的例外是:

> The specified type was not recognized: name='TResponse', namespace='urn:ETS', at <V2Return xmlns='urn:ETS'> 

我在Reference.cs有效TResponse类,请让我知道如果这可以通过处理改变配置,我期待WCF客户端解析任何肥皂消息,但它不能,我不能改变任何东西在服务器端,这是第三方API。

+0

你的服务有WSDL吗? – Aron

+0

是的我有wsdl,我在我的.Net项目中添加服务参考 – MSUH

+0

V2Return是否继承了TResponse? – Adil

回答

1

我能够通过在由svcutil.exe生成的代理类中手动更改名称空间来解决此问题。 “TResponse”类在代理代码中定义了一些不同的名称空间,当我将命名空间更改为urn:ETS时,soap响应很容易反序列化到类中。在此之前,我已经检查了SoapUI的响应并验证了肥皂响应,并且所有内容都看起来很完美,然后我搜索到了并找到了This url。在再次读取异常之后,我意识到这个问题出现在命名空间中。

下面是变化的,我做到了:

/// <remarks/> 
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.4927")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://axis.webservices.api.etransactions")] 
    public partial class TResponse : object, System.ComponentModel.INotifyPropertyChanged { 
     ........ 

我取代 “http://axis.webservices.api.etransactions” 与 “瓮:ETransactionsService” 和它的工作,:)!

相关问题