SoapHttpClientProtocol log response xml

和自甴很熟 提交于 2019-12-08 16:53:08

问题


For a couple of days we have problem with our app. We use SoapHttpClientProtocol in order to invoke java mbeans. This basically makes a call to a java webservice to invoke methods.

Our problem is that sometimes we get the following exception:

There is an error in XML document (1, 172089). at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) 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 DynamicMBeanResourceBinding.Invoke(OperationRequestType ManagedResourceOperation) in JMXConnectorService.cs:line 781 at JMXWSClient.InvokeMethodOnObject(String objectName, String methodName, ParameterType[] paramValue) in connectivity\Client.cs:line 132

Caused by: Unexpected end of file has occurred. The following elements are not closed: Icon

Our last code in the communication layer is:

 /// <remarks/>
[System.Web.Services.Protocols.SoapHeaderAttribute("soapHeaders", Direction = SoapHeaderDirection.In)]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://jsr262.dev.java.net/DynamicMBeanResource/Invoke", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("ManagedResourceOperationResult", Namespace = "http://jsr262.dev.java.net/jmxconnector")]
public GenericValueType Invoke([System.Xml.Serialization.XmlElementAttribute(Namespace = "http://jsr262.dev.java.net/jmxconnector")] OperationRequestType ManagedResourceOperation)
{
    object[] results = this.Invoke("Invoke", new object[] {ManagedResourceOperation});
    return ((GenericValueType)(results[0]));
}

Is there any way of logging the response xml before is being deserialized by the framework? Any help or idea is very welcomed.


回答1:


The easiest way for doing this in a clean manner is to create a SOAP extension. I found a good tutorial here.

http://www.codeproject.com/KB/webservices/efficientsoapextension.aspx



来源:https://stackoverflow.com/questions/7684671/soaphttpclientprotocol-log-response-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!