SOAP Web服务响应解组错误

时间:2019-02-23 01:18:07

标签: c# web-services serialization soap

我正在使用SOAP Web服务,并调用其响应在WSDL中定义如下的方法-

<wsdl:operation name="changeRecording">
            <wsdl:input message="tns:changeRecording" name="changeRecording">
            </wsdl:input>
            <wsdl:output message="tns:changeRecordingResponse" name="changeRecordingResponse">
            </wsdl:output>
            <wsdl:fault message="tns:CaptureWebServiceException" name="CaptureWebServiceException">
            </wsdl:fault>
        </wsdl:operation>

<xs:complexType name="changeRecordingResponse">
                <xs:sequence>
                    <xs:element name="return" type="xs:boolean"/>
                </xs:sequence>
            </xs:complexType>

我在C#中创建了代理类,将其解释为-

 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace = "http://webservice.sdk.ingest.automation.avid.com/", ResponseNamespace = "http://webservice.sdk.ingest.automation.avid.com/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [return: System.Xml.Serialization.XmlElementAttribute("return", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public bool changeRecording([System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] userCredentials userCredentials, [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] scheduleChangeParams changeEvent)
        {
            object[] results = this.Invoke("changeRecording", new object[] {
                        userCredentials,
                        changeEvent});
            return ((bool)(results[0]));
        }

请注意,方法为changeRecording,返回类型为bool。

我用代码将此Web服务称为-

bool result = avidClient.changeRecording(<params>);

但出现以下错误-

System.Web.Services.Protocols.SoapHeaderException: Unmarshalling Error: null 
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at ScheduleClientService.changeRecording(userCredentials userCredentials, scheduleChangeParams changeEvent)

似乎Web服务正在返回NULL值而不是布尔值。这就是为什么解组/反序列化失败的原因。

我的假设正确吗?是服务中的错误还是我做错了什么?

0 个答案:

没有答案