当我尝试通过WCF API调用获取工单状态时收到以下错误:
反序列化操作'getWorkOrderStatus'的回复消息正文时出错。 OperationFormatter遇到无效的Message正文。预计会找到名为'getWorkOrderStatusResponse'和名称空间''的节点类型'Element'。找到名为'SOAP-ENV:getWorkOrderStatusResponse'的节点类型'Element'和名称空间'http://schemas.xmlsoap.org/soap/envelope/'
这是一个新的.Net Core项目(4.6.1。)。我使用https://www.fieldnation.com/api/v3.3/fieldnation.wsdl中的srvcutil 4.6.1创建了代理类。我不得不评论一些自动生成的属性,因为.net核心似乎没有它们。这很可能导致问题之一,但我不知道解决方法是什么。
这是我使用SOAP UI获得的实际响应:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<SOAP-ENV:getWorkOrderStatusResponse>
<return xsi:type="xsd:string">Assigned</return>
</SOAP-ENV:getWorkOrderStatusResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
以下是我能找到的与生成的代码相关的任何内容:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
//[System.ServiceModel.MessageContractAttribute(WrapperName="getWorkOrderStatusResponse", WrapperNamespace="", IsWrapped=true)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "SOAP-ENV:getWorkOrderStatusResponse", WrapperNamespace = "http://schemas.xmlsoap.org/soap/envelope/", IsWrapped = true)]
public partial class getWorkOrderStatusResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
public string @return;
public getWorkOrderStatusResponse()
{
}
public getWorkOrderStatusResponse(string @return)
{
this.@return = @return;
}
}