SOAP Webservice error in parameters

lsanagustinlsanagustin Member Posts: 2
edited 2010-09-24 in NAV Three Tier
Hi!
I´ve a webservice over JBoss App server.
The webservice definition is
<definitions name='GasoilServiceService' targetNamespace='http://gasoil.interna.iop.comet.carreras/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://gasoil.interna.iop.comet.carreras/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'&gt;
<types>
<xs:schema targetNamespace='http://gasoil.interna.iop.comet.carreras/' version='1.0' xmlns:tns='http://gasoil.interna.iop.comet.carreras/' xmlns:xs='http://www.w3.org/2001/XMLSchema'&gt;
<xs:element name='Exception' type='tns:Exception'/>
<xs:complexType name='Exception'>
<xs:sequence>
<xs:element minOccurs='0' name='message' type='xs:string'/>
</xs:sequence>
</xs:complexType>
<xs:complexType name='operacion'>
<xs:sequence>
<xs:element minOccurs='0' name='cantidad' type='xs:double'/>
<xs:element minOccurs='0' name='claseTarjeta' type='xs:int'/>
<xs:element minOccurs='0' name='codCliente' type='xs:int'/>
<xs:element minOccurs='0' name='codEstacionServicio' type='xs:int'/>
<xs:element minOccurs='0' name='codOperacion' type='xs:int'/>
<xs:element minOccurs='0' name='codTarjeta' type='xs:int'/>
<xs:element minOccurs='0' name='codTarjetaExterno' type='xs:string'/>
<xs:element minOccurs='0' name='conductor' type='xs:string'/>
<xs:element minOccurs='0' name='fechaFactura' type='xs:dateTime'/>
<xs:element minOccurs='0' name='fechaOperacion' type='xs:dateTime'/>
<xs:element minOccurs='0' name='kilometros' type='xs:int'/>
<xs:element minOccurs='0' name='matricula' type='xs:string'/>
<xs:element minOccurs='0' name='numFactura' type='xs:string'/>
<xs:element minOccurs='0' name='precioUnitario' type='xs:double'/>
<xs:element minOccurs='0' name='producto' type='xs:int'/>
<xs:element minOccurs='0' name='productoDescripcion1' type='xs:string'/>
<xs:element minOccurs='0' name='productoDescripcion2' type='xs:string'/>
</xs:sequence>
</xs:complexType>
<xs:complexType name='cotizacionProductos'>
<xs:sequence>
<xs:element minOccurs='0' name='fechaCotizacion' type='xs:dateTime'/>
<xs:element maxOccurs='unbounded' minOccurs='0' name='productos' nillable='true' type='tns:producto'/>
</xs:sequence>
</xs:complexType>
<xs:complexType name='producto'>
<xs:sequence>
<xs:element minOccurs='0' name='codigo' type='xs:int'/>
<xs:element minOccurs='0' name='descripcion' type='xs:string'/>
<xs:element minOccurs='0' name='precioUltimaCompra' type='xs:double'/>
</xs:sequence>
</xs:complexType>
<xs:complexType final='#all' name='operacionArray'>
<xs:sequence>
<xs:element maxOccurs='unbounded' minOccurs='0' name='item' nillable='true' type='tns:operacion'/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name='GasoilService_actualizarPrecioProductosResponse'></message>
<message name='GasoilService_getOperaciones'>
<part name='usucod' type='xsd:string'></part>
<part name='clicod' type='xsd:int'></part>
<part name='fecdes' type='xsd:string'></part>
<part name='fechas' type='xsd:string'></part>
</message>
<message name='GasoilService_actualizarPrecioProductos'>
<part name='arg0' type='xsd:string'></part>
<part name='arg1' type='tns:cotizacionProductos'></part>
</message>
<message name='GasoilService_pingResponse'>
<part name='return' type='xsd:string'></part>
</message>
<message name='Exception'>
<part element='tns:Exception' name='Exception'></part>
</message>
<message name='GasoilService_getOperacionesResponse'>
<part name='return' type='tns:operacionArray'></part>
</message>
<message name='GasoilService_ping'></message>
<portType name='GasoilService'>
<operation name='actualizarPrecioProductos' parameterOrder='arg0 arg1'>
<input message='tns:GasoilService_actualizarPrecioProductos'></input>
<output message='tns:GasoilService_actualizarPrecioProductosResponse'></output>
<fault message='tns:Exception' name='Exception'></fault>
</operation>
<operation name='getOperaciones' parameterOrder='usucod clicod fecdes fechas'>
<input message='tns:GasoilService_getOperaciones'></input>
<output message='tns:GasoilService_getOperacionesResponse'></output>
<fault message='tns:Exception' name='Exception'></fault>
</operation>
<operation name='ping'>
<input message='tns:GasoilService_ping'></input>
<output message='tns:GasoilService_pingResponse'></output>
<fault message='tns:Exception' name='Exception'></fault>
</operation>
</portType>
<binding name='GasoilServiceBinding' type='tns:GasoilService'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/&gt;
<operation name='actualizarPrecioProductos'>
<soap:operation soapAction=''/>
<input>
<soap:body namespace='http://gasoil.interna.iop.comet.carreras/' use='literal'/>
</input>
<output>
<soap:body namespace='http://gasoil.interna.iop.comet.carreras/' use='literal'/>
</output>
<fault name='Exception'>
<soap:fault name='Exception' use='literal'/>
</fault>
</operation>
<operation name='getOperaciones'>
<soap:operation soapAction=''/>
<input>
<soap:body namespace='http://gasoil.interna.iop.comet.carreras/' use='literal'/>
</input>
<output>
<soap:body namespace='http://gasoil.interna.iop.comet.carreras/' use='literal'/>
</output>
<fault name='Exception'>
<soap:fault name='Exception' use='literal'/>
</fault>
</operation>
<operation name='ping'>
<soap:operation soapAction=''/>
<input>
<soap:body namespace='http://gasoil.interna.iop.comet.carreras/' use='literal'/>
</input>
<output>
<soap:body namespace='http://gasoil.interna.iop.comet.carreras/' use='literal'/>
</output>
<fault name='Exception'>
<soap:fault name='Exception' use='literal'/>
</fault>
</operation>
</binding>
<service name='GasoilServiceService'>
<port binding='tns:GasoilServiceBinding' name='GasoilServicePort'>
<soap:address location='http://192.168.10.203:8181/comet-iop/GasoilService'/&gt;
</port>
</service>
</definitions>


The xml sended to Webservice (to method getOperaciones) is:
<Soap:Envelope xmlns:Soap="http://schemas.xmlsoap.org/wsdl/soap/&quot; xmlns:tns="http://gasoil.interna.iop.comet.carreras/&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
<Soap:Body>
<getOperaciones xmlns="http://gasoil.interna.iop.comet.carreras/"&gt;
<usucod>user</usucod>
<clicod>1</clicod>
<fecdes>01/08/2010</fecdes>
<fechas>31/08/2010</fechas>
</getOperaciones>
</Soap:Body>
</Soap:Envelope>


the webservice returns the next error
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<env:Header />
<env:Body>
<env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<faultcode>env:Server</faultcode>
<faultstring>Cannot find child element: usucod</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>


The Navision Object Codeunit is:

OBJECT Codeunit 50009 WebService Gasoil
{
OBJECT-PROPERTIES
{
Date=24/09/10;
Time=[ 8:57:43];
Modified=Yes;
Version List=;
}
PROPERTIES
{
OnRun=BEGIN
Selection := STRMENU('&ping,&getOperaciones',2);
CASE Selection OF
0: EXIT;
1: WS_HTTP_PING;
2: WS_HTTP_getOperaciones;

END;
END;

}
CODE
{
VAR
CompanyInfo@1000000000 : Record 79;
Selection@1000000001 : Integer;

PROCEDURE InvokeNavWS@1000000000(URL@1000000011 : Text[250];method@1000000012 : Text[250];namespace@1000000013 : Text[80];returnTag@1000000001 : Text[30];parameters@1000000014 : Text[1024];VAR nodeList@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF82-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMNodeList") result : Boolean;
VAR
xmlhttp@1000000023 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{F6D90F16-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v4.0'.XMLHTTP";
xmldoc@1000000022 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v4.0'.DOMDocument";
soapEnvelope@1000000021 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMElement";
soapBody@1000000020 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMElement";
soapMethod@1000000019 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF86-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMElement";
node@1000000018 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMNode";
parametersXmlDoc@1000000017 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v4.0'.DOMDocument";
node2@1000000002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMNode";
BEGIN
//Chequear datos
IF (URL = '') OR (method = '') OR (namespace = '') OR (returnTag = '') THEN EXIT(FALSE);

// Create XML Document
CREATE(xmldoc,TRUE);

// Create SOAP Envelope
soapEnvelope := xmldoc.createElement('Soap:Envelope');
soapEnvelope.setAttribute('xmlns:Soap', 'http://schemas.xmlsoap.org/soap/envelope/');
soapEnvelope.setAttribute('Use','SoapBindingUse.Literal');
xmldoc.appendChild(soapEnvelope);

// Create SOAP Body
soapBody := xmldoc.createElement('Soap:Body');
soapEnvelope.appendChild(soapBody);

// Create Method Element
soapMethod := xmldoc.createElement(method);
soapMethod.setAttribute('xmlns',namespace);
soapBody.appendChild(soapMethod);

// Transfer parameters by loading them into a XML Document and move them
IF parameters <> '' THEN BEGIN
CREATE(parametersXmlDoc,TRUE);
parametersXmlDoc.loadXML('<parameters>'+parameters+'</parameters>');
IF parametersXmlDoc.firstChild.hasChildNodes THEN BEGIN
WHILE parametersXmlDoc.firstChild.childNodes.length > 0 DO BEGIN
node := parametersXmlDoc.firstChild.firstChild;
node := parametersXmlDoc.firstChild.removeChild(node);
//MESSAGE(node.nodeName + ' - ' + node.text);
soapMethod.appendChild(node);
END;
END;
END;

// Create XMLHTTP and SEND
CREATE(xmlhttp,TRUE);
xmlhttp.open('POST',URL,FALSE);
xmlhttp.setRequestHeader('Content-type', 'text/xml; charset=utf-8');
xmlhttp.setRequestHeader('SOAPAction', method);
xmlhttp.send(xmldoc);

// If status is OK - Get Result XML
IF xmlhttp.status = 200 THEN BEGIN
xmldoc.async := FALSE;
xmldoc.load(xmlhttp.responseXML);
xmldoc.save('C:\temp.xml'); //Si queremos guardar el resultado en fichero -- para temas de log

//xmldoc.setProperty('SelectionLanguage','XPath');
//xmldoc.setProperty('SelectionNamespaces','xmlns:tns="'+namespace+'"');
//nodeList := xmldoc.selectNodes('//tns:'+returnTag);
result := TRUE;

nodeList := xmldoc.getElementsByTagName(returnTag);
END ELSE BEGIN
xmldoc.async := FALSE;
xmldoc.load(xmlhttp.responseXML);
xmldoc.save('C:\temp.xml');

nodeList := xmldoc.getElementsByTagName('faultstring');
END;
END;

PROCEDURE WS_HTTP_PING@1000000003();
VAR
method@1000000008 : Text[200];
namespace@1000000009 : Text[200];
parameters@1000000011 : Text[1024];
returnTag@1000000001 : Text[30];
DOMNodelist@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF82-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMNodeList";
BEGIN
CompanyInfo.GET;

method := 'ping';
namespace := 'http://gasoil.interna.iop.comet.carreras/';
parameters := '';
returnTag := 'return';

IF InvokeNavWS(CompanyInfo."URL WS Facturacion Gasoil",method,namespace,returnTag,parameters,DOMNodelist) THEN BEGIN
END ELSE ERROR('Ha ocurrido un error.');

IF DOMNodelist.length = 0 THEN MESSAGE(DOMNodelist.item(0).text)
ELSE MESSAGE(DOMNodelist.item(0).text);
END;

PROCEDURE WS_HTTP_getOperaciones@1000000005();
VAR
method@1000000008 : Text[200];
namespace@1000000009 : Text[200];
parameters@1000000010 : Text[1024];
returnTag@1000000012 : Text[30];
DOMNodelist@1000000000 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 4.0:{2933BF82-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v4.0'.IXMLDOMNodeList";
BEGIN
CompanyInfo.GET;

method := 'getOperaciones';
namespace := 'http://gasoil.interna.iop.comet.carreras/';
parameters := '<arg0>jarribas</arg0><arg1>1</arg1><arg2>01/08/2010</arg2><arg3>31/08/2010</arg3>';
returnTag := 'return';

IF InvokeNavWS(CompanyInfo."URL WS Facturacion Gasoil",method,namespace,returnTag,parameters,DOMNodelist) THEN BEGIN
END ELSE ERROR('Ha ocurrido un error.');

IF DOMNodelist.length = 0 THEN MESSAGE(DOMNodelist.item(0).text)
ELSE MESSAGE(DOMNodelist.item(0).text);

END;


}
}



I run the codeunit against a webservice with type rpc and use encode, and works fine, but with this webservice with type rpc and use literal, doesn't work.

If i run the ping function, which not sends parameters, works fine.

Anybody has any idea??
thanks in advance.
Sign In or Register to comment.