I'm new to this soap message and stuff, I'm having some troubles using a WebService, I created a Class using WSDL.exe, the first issue I had was when the command was executed, it created a parameter with var[][] which I had to replace for a single var[] (array).
Then it was successfully compiling, now I having some issues and I have no idea how to fix it:
The request I'm sending is this one:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<emitirWS xmlns="http://neon.stoconsulting.com/NeonEmisionWS/NeonEmisionWS?wsdl">
<comprobante serie="W" folio="143" formaPago="01" condicionesDePago="CONTADO" tipoCambio="1.000000" moneda="MXN" metodoPago="PUE" lugarExpedicion="54080" tipoComprobante="I" subTotal="827.586207" descuento="0.000000" total="960.00" documentoErp="143" usoCfdi="G03" tipoDocumento="1">
<envioCfdi enviarXml="1" enviarPdf="1" enviarZip="0" emails="[email protected]" />
<emisor rfc="ASM160607Q43" nombre="ARTHUR AND SONS MEXICO" regimenFiscal="601" idEmisorSto="1" idEmisorErp="1" />
<sucursal rfc="ASM160607Q43" nombre="Plaza Polanco" regimenFiscal="601" idEmisorSto="2" idEmisorErp="2" numeroExterior="411" calle="Avenida Palmas" colonia="Miguel Hidalgo" referencia="" municipio="Toluca" estado="Edo. de México" pais="Mexico" codigoPostal="54080" email="[email protected]" idTipoEmisor="2" idEmisorPadre="1" estatusRegistro="1" />
<receptor rfc="PIVF810724LW9" nombre="Felipe Pina Vera" regimenFiscal="622" usoCfdi="G01" idReceptoSto="1" idReceptorErp="1" numeroExterior="141A" calle="Viveros de Coyoacán" colonia="Viveros de la Loma" municipio="Tlalnepantla" estado="Edo. de México" pais="Mexico" codigoPostal="54080" email="[email protected]" idEmisorPadre="0" estatusRegistro="1" />
<conceptos claveProdServ="42142901" cantidad="1.000000" claveUnidad="H87" unidad="Pieza" numIdentificacion="5" descripcion="BENSEN - AZUL" valorUnitario="827.586207" importe="827.586207" descuento="0.000000" xmlns="">
<impuestos>
<trasladados base="827.586207" impuesto="002" tipoFactor="Tasa" tasaOCuota="0.160000" importe="132.413793" />
</impuestos>
</conceptos>
<impuestos totalImpuestosRetenidos="0.000000" totalImpuestosTrasladados="132.413793" xmlns="">
<trasladados impuesto="002" tipoFactor="Tasa" tasaOCuota="0.160000" importe="132.413793" />
</impuestos>
</comprobante>
</emitirWS>
</soap:Body>
</soap:Envelope>
When it reaches to the server, it cannot be processed since the request doesn't have the right format, the right format is this one:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:neon="http://neon.stoconsulting.com/NeonEmisionWS/NeonEmisionWS?wsdl">
<soap:Body>
<neon:emitirWS>
<comprobante serie="W" folio="143" formaPago="01" condicionesDePago="CONTADO" tipoCambio="1.000000" moneda="MXN" metodoPago="PUE" lugarExpedicion="54080" tipoComprobante="I" subTotal="827.586207" descuento="0.000000" total="960.00" documentoErp="143" usoCfdi="G03" tipoDocumento="1">
<envioCfdi enviarXml="1" enviarPdf="1" enviarZip="0" emails="[email protected]" />
<emisor rfc="ASM160607Q43" nombre="ARTHUR AND SONS MEXICO" regimenFiscal="601" idEmisorSto="1" idEmisorErp="1" />
<sucursal rfc="ASM160607Q43" nombre="Plaza Polanco" regimenFiscal="601" idEmisorSto="2" idEmisorErp="2" numeroExterior="411" calle="Avenida Palmas" colonia="Miguel Hidalgo" referencia="" municipio="Toluca" estado="Edo. de México" pais="Mexico" codigoPostal="54080" email="[email protected]" idTipoEmisor="2" idEmisorPadre="1" estatusRegistro="1" />
<receptor rfc="PIVF810724LW9" nombre="Felipe Pina Vera" regimenFiscal="622" usoCfdi="G01" idReceptoSto="1" idReceptorErp="1" numeroExterior="141A" calle="Viveros de Coyoacán" colonia="Viveros de la Loma" municipio="Tlalnepantla" estado="Edo. de México" pais="Mexico" codigoPostal="54080" email="[email protected]" idEmisorPadre="0" estatusRegistro="1" />
<conceptos claveProdServ="42142901" cantidad="1.000000" claveUnidad="H87" unidad="Pieza" numIdentificacion="5" descripcion="BENSEN - AZUL" valorUnitario="827.586207" importe="827.586207" descuento="0.000000">
<impuestos>
<trasladados base="827.586207" impuesto="002" tipoFactor="Tasa" tasaOCuota="0.160000" importe="132.413793" />
</impuestos>
</conceptos>
<impuestos totalImpuestosRetenidos="0.000000" totalImpuestosTrasladados="132.413793">
<trasladados impuesto="002" tipoFactor="Tasa" tasaOCuota="0.160000" importe="132.413793" />
</impuestos>
</comprobante>
</neon:emitirWS>
</soap:Body>
</soap:Envelope>
I need to switch:
in envelope node, I need to add a new attribute:
xmlns:neon="http://neon.stoconsulting.com/NeonEmisionWS/NeonEmisionWS?wsdl"
on emitir node, I need it needs to be
<neon:emitir></neon:emitir>
instead of the regular<emitir>
When I do that everything works like a charm, like I said I created the class with the wsdl.exe tool, this is the code I'm using:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace = "http://neon.stoconsulting.com/NeonEmisionWS/NeonEmisionWS?wsdl", ResponseNamespace = "http://neon.stoconsulting.com/NeonEmisionWS/NeonEmisionWS?wsdl", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("RespuestaWS", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
[WebServiceSOAPExtension]
public respuestaWS emitirWS(comprobante comprobante)
{
object[] results = this.Invoke("emitirWS", new object[] {
comprobante});
return ((respuestaWS)(results[0]));
}
Thanks, I have no idea where to begin.
Well for all the guys over there who are triying to do something like this and you have no idea, i ended up doing some nasty stuff that i don't recommed, however if you are stuck like me and you have no clue where to begin to do it the "right" way, well you can do this:
First, you need to create a class that extends
SoapExtension
Like this one:}
And then use a custom attribute on the proxy's method to replace the actual Stream with your custom stream, the writeOutput method is for the "request" and the writeInput method is for the "response", then you need to play with your strings to fit your needs, i hope it helps.
As i mentioned on the first lines, this is not the right way to it, however if you are like me with no clue where to begin, you can write your custom Xml string.