Options

Sending to NAV 2009 Webservice from NAV 4.X

lyotlyot Member Posts: 202
edited 2010-03-29 in NAV Three Tier
I've been messing around for some while now this subject.
But I guess now I've really hit a brick wall.

I'm trying to send the result of an xml port in NAV 4 SP1 to a 2009 web service.
First of all I've written a similar application in .NET, who uses to exposed xmlport in the 2009 web service to insert a customer.
This works like a charm. I've captured the xml file that is send by the .Net application with Wireshark.
It looks like this:
<?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>
	  <CustomerUpdate xmlns="urn:microsoft-dynamics-schemas/codeunit/WebserviceListener">
	    <customerWebservice>
	      <Customer xmlns="urn:microsoft-dynamics-nav/xmlports/WebserviceListener">
		    <No>PROT</No>
		  </Customer>
        </customerWebservice>
	  </CustomerUpdate>
    </soap:Body>
  </soap:Envelope>

Then I made a xmlport in NAV 4 SP1 who generates the (almost) thesame xml file as the one above.
The result of the xmlport is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
		<CustomerUpdate xmlns="urn:microsoft-dynamics-schemas/codeunit/WebserviceListener">
			<customerWebservice>
				<Customer xmlns="urn:microsoft-dynamics-nav/xmlports/WebserviceListener">
					<No>PROT</No>
				</Customer>
			</customerWebservice>
		</CustomerUpdate>
	</soap:Body>
</soap:Envelope>

This xml file is loaded in a xmlDocument automation ('Microsoft XML, v6.0'.DOMDocument) through an instream ad the sent with a xmlHttp automation ('Microsoft XML, v6.0'.XMLHTTP60)
...
lautXmlHttp.send(lautXmlDoc);
...

I keep getting the following answer back from the webservice:
a:System.Net.WebException Soap message is invalid!

Ok some might have noticed that the two xml files are not exactly the same.
encoding="UTF-8" <> encoding="utf-8"
standalone="no" <> not present

So I've made a test function that loads the xml content (text without use of xmlport) in a xmlHttp automation.
lautXmlHttp.send('<?xml version="1.0" encoding="UTF-8" standalone="no"?>'+
  '<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>'+
  '<CustomerUpdate xmlns="urn:microsoft-dynamics-schemas/codeunit/WebserviceListener">'+
  '<customerWebservice>'+
  '<Customer xmlns="urn:microsoft-dynamics-nav/xmlports/WebserviceListener">' +
  '<No>PROT3</No>' +
  '</Customer>' +
  '</customerWebservice>' +
  '</CustomerUpdate>' +
  '</soap:Body>' +
  '</soap:Envelope>');

This however works fine! ](*,) ](*,) ](*,) ](*,) ](*,) ](*,)
This is really getting on my nerves because working without xmlports in NOT an option.

Comments

  • Options
    lyotlyot Member Posts: 202
    Maybe not insignificant but the result of my xmlport is stored in a temp blob.
    And then loaded with in- & outstreams in the xml document automation object.
  • Options
    lyotlyot Member Posts: 202
    Eliminated temp blob part but still the same result... :|
  • Options
    lyotlyot Member Posts: 202
    Euhmm I'm not doing an upgrade from 4 to 2009 SP1.
  • Options
    ara3nara3n Member Posts: 9,255
    Have you looked at the following post.

    It shows how to set the header and communicate with NAV 2009 webservice.

    http://mibuso.com/blogs/ara3n/2009/01/2 ... companies/



    It could be that xmlport add linefeed and carriage return after each element, which needs to be removed.


    You could load the blob into xmldom and see if there is a way to remove
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.