I have a problem with the consumption of WS
registered by VS
, the error that returns is related to the deserialization of the response.
Code:
using (ErpServiceSOAPPortClient service = new ErpServiceSOAPPortClient())
{
BoletoDTO _boleto = new BoletoDTO();
_boleto.idNegociacao = 0;
_boleto.pdf = "teste";
ArrayOfBoletodto _arrBoletos = new ArrayOfBoletodto();
_arrBoletos.item = new BoletoDTO[1];
_arrBoletos.item[0] = _boleto;
BoletosDTO _boletos = new BoletosDTO();
_boletos.boletos = _arrBoletos;
var _resp = service.enviarBoleto(1, _boletos);
}
Exception:
System.ServiceModel.CommunicationException was unhandled by user code HResult=-2146233087 Message=Error in deserializing body of reply message for operation 'enviarBoleto'. Source=mscorlib StackTrace:
Server stack trace:
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at WebApplication1.ServiceReference1.ErpServiceSOAPPort.enviarBoleto(Int32 numBoletos, BoletosDTO boletosDTO)
at WebApplication1.ServiceReference1.ErpServiceSOAPPortClient.enviarBoleto(Int32 numBoletos, BoletosDTO boletosDTO) in C:\Users\marciel.torres\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1\Service References\ServiceReference1\Reference.cs:line 835
at WebApplication1._default.Page_Load(Object sender, EventArgs e) in C:\Users\marciel.torres\Documents\Visual Studio 2015\Projects\WebApplication1\WebApplication1\default.aspx.cs:line 29
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException:
HResult=-2146233079
Message=There is an error in XML document (2, 738).
Source=System.Xml
StackTrace:
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
InnerException:
HResult=-2147467262
Message=Cannot assign object of type WebApplication1.ServiceReference1.ResponseDTO to an object of type WebApplication1.ServiceReference1.ResponseDTO[].
Source=1qxqreec
StackTrace:
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderErpServiceSOAPPort.Read7_ArrayOfResponsedto()
at System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(String name, String ns, Boolean elementCanBeType, String& fixupReference)
at System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(String name, String ns, String& fixupReference)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderErpServiceSOAPPort.Read6_ResponsesDTO()
at System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(String name, String ns, Boolean elementCanBeType, String& fixupReference)
at System.Xml.Serialization.XmlSerializationReader.ReadReferencingElement(String name, String ns, String& fixupReference)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderErpServiceSOAPPort.Read25_enviarBoletoResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer5.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
InnerException:
Follow the print as requested: