Parse xml to webservice

SilentpowerSilentpower Member Posts: 13
Hello,

I've a webservice in .NET (C#) with a function that expects a xml file.

When I call this function from navision I would like to pass an xml file.

This is the code:
IF ISCLEAR(autXMLDom) THEN
  CREATE(autXMLDom);

recTmpBlob.Blob.CREATEOUTSTREAM(strOutStream);

//xmlFA.SETDESTINATION(strOutStream);

IF XMLPORT.EXPORT(50000, strOutStream, precJob) THEN BEGIN
  recTmpBlob.Blob.CREATEINSTREAM(strInStream);
  autXMLDom.load(strInStream);
  lblnExportOK:=TRUE
END ELSE BEGIN
  lblnExportOK:=FALSE;
END;

autXMLDom.save('c:/test1.xml');






IF ISCLEAR(SoapHttpConn) THEN BEGIN
  CREATE(SoapHttpConn);
END;
SoapHttpConn.Property('EndPointURL','http://localhost/WTWebService/SyncJobs.asmx');
SoapHttpConn.Connect; 
SoapHttpConn.Property('SoapAction','http://tempuri.org/JobExists');
SoapHttpConn.BeginMessage; 

IF ISCLEAR(SoapSerialize) THEN BEGIN
  CREATE(SoapSerialize);
END;
SoapSerialize.Init(SoapHttpConn.InputStream); 
SoapSerialize.StartEnvelope('','STANDARD'); 
SoapSerialize.StartBody; 
SoapSerialize.WriteXml('<JobExists xmlns="http://tempuri.org/" />');
//----------------------------------------------------------------------------------------------------------------------------------
//*** Parameters doorgeven
//----------------------------------------------------------------------------------------------------------------------------------
SoapSerialize.WriteXml('<JobExists xmlns="http://tempuri.org/">' +
                          '<xmlJob></xmlJob>' +
                          '</JobExists>');
SoapSerialize.EndBody; 
SoapSerialize.EndEnvelope; 
SoapHttpConn.EndMessage; 

IF ISCLEAR(pxmlJobExists) THEN BEGIN
  CREATE(pxmlJobExists);
END;
pxmlJobExists.async := FALSE;
pxmlJobExists.load(SoapHttpConn.OutputStream);

pxmlJobExists.save('c:/test.xml');


EXIT(lblnExportOK);

But it doesn't work, this is the xml that I receive:
<?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>
		<soap:Fault>
			<faultcode>soap:Client</faultcode>
			<faultstring>Server was unable to read request. --> There is an error in XML document (1, 482). --> Cannot import a null node.</faultstring>
			<detail/>
		</soap:Fault>
	</soap:Body>
</soap:Envelope>

Does anyone know how to pass an xml file to a webservice function?

Tnx!

Comments

  • SilentpowerSilentpower Member Posts: 13
    nobody?
  • jhoekjhoek Member Posts: 216
    Hi Silentpower,

    I seem to experience the same problem here. Parameters passed from Navision using the SOAP Toolkit are received by the webservice as blank values.

    I will keep you posted, should I find a solution. Will you do the same? :)
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • jhoekjhoek Member Posts: 216
    Could it be a namespace problem?
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • egonyegony Member Posts: 1
    Hi,

    your webservice expects a string. So you have to encode your inner XML-document.

    <myInnerNode> = > <myInnerNode/>

    egony
  • jhoekjhoek Member Posts: 216
    I think I understand what you mean. Thanks - I'll give it a try!
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • KTAKTA Member Posts: 11
    Hy,

    I'm made the same search and I find sample on MSDN : http://msdn.microsoft.com/MBS/TechArticles/Navision/default.aspx

    There are two links that show you how to communicate between a web service and Navision trought MS Mqueue.

    I succeed to develop it. It's fun and open many opportunities... I hope for you too :D
  • jhoekjhoek Member Posts: 216
    The problem is: I need my solution to be synchronous, i.e. I don't need the extra complexity of MSMQ to make it asynchronous. :(
    Kind regards,

    Jan Hoek
    Product Developer
    Mprise Products B.V.
  • RaRoldanRaRoldan Member Posts: 2
    KTA wrote:
    Hy,

    I'm made the same search and I find sample on MSDN : http://msdn.microsoft.com/MBS/TechArticles/Navision/default.aspx

    There are two links that show you how to communicate between a web service and Navision trought MS Mqueue.

    I succeed to develop it. It's fun and open many opportunities... I hope for you too :D

    This is exactly what I have been looking for for days :D Thanks
Sign In or Register to comment.