Xml file with xmlhttp request

Kisu
Member Posts: 381
Heyas, been reading your post ara3n and blog about http requests and webservice. mm and it made me think of something.
Some of our clients needs an integration with webservices now and it could be done with similar http requests you've done with the yahoo thingy.
Thing is that I'd like to save time and use some of our xml ports like for invoicing and customer transfering but adding them with the http requests.
On the blog where you made the verification you used these automations:
XmlHttp Automation 'Microsoft XML, v6.0'.ServerXMLHTTP
XmlDoc Automation 'Microsoft XML, v6.0'.DOMDocument
XmlNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
do you think I could add the xml file with its contens I export on server disk on the http request somehow (if there is function or streaming) or would there be better/other way?
The xml files I've made use same DTD as client's webservice asks. :-k
Some of our clients needs an integration with webservices now and it could be done with similar http requests you've done with the yahoo thingy.
Thing is that I'd like to save time and use some of our xml ports like for invoicing and customer transfering but adding them with the http requests.
On the blog where you made the verification you used these automations:
XmlHttp Automation 'Microsoft XML, v6.0'.ServerXMLHTTP
XmlDoc Automation 'Microsoft XML, v6.0'.DOMDocument
XmlNode Automation 'Microsoft XML, v6.0'.IXMLDOMNode
do you think I could add the xml file with its contens I export on server disk on the http request somehow (if there is function or streaming) or would there be better/other way?
The xml files I've made use same DTD as client's webservice asks. :-k
K.S.
0
Answers
-
0
-
Nifty,
I managed to build code for the webservice.
But when I send the request along with the headers and the xml file to the destination url.
It does not receive that. (according to our customer) And the response.xml is 0KB afterwards :-k
I added messages along my code and it does create xml, add it to the request,
it should add the headers as clients needs
xmlhttp.status gives 200 OKK.S.0 -
Hi
Normally I would prefer to use the xmlHttp object as an automation. It's a bit tedious to build the xml with DOM, but you retain full control of everything.
Have a look here, it's an excellent example.
http://www.mibuso.com/dlinfo.asp?FileID=539
Regards
Thomas0 -
Hmm, the file definetely goes to the webservice, we can see it at customers place but we dont get response.xml still. Odd
Do I need to set up something for the sending server where the nav client is?
It would speed things up with the testing if I'd get some response other than status 200 back :-kK.S.0 -
Kisu wrote:Hmm, the file definetely goes to the webservice, we can see it at customers place but we dont get response.xml still. Odd
Do I need to set up something for the sending server where the nav client is?
It would speed things up with the testing if I'd get some response other than status 200 back :-k
Did you test with the link from my previous post? Very easy to adapt to another xml structure.
Thomas0 -
ta5 wrote:Kisu wrote:Hmm, the file definetely goes to the webservice, we can see it at customers place but we dont get response.xml still. Odd
Do I need to set up something for the sending server where the nav client is?
It would speed things up with the testing if I'd get some response other than status 200 back :-k
Did you test with the link from my previous post? Very easy to adapt to another xml structure.
Thomas
Yes I downloaded the file and checked it out, I'm realy not sure what are you pointing with the code. It looks similar than mine.
We are not using soap with this integration and the webservice is REST type thingy.
I added code Rashed gave on one post that checks the response message and I get this error from it:
XML -document has to have upperlevel element - errorcode: -1072896680
:?K.S.0 -
Hmm and if I try to get the response as txt it overflows text buffer.K.S.0
-
Hi Kisu
Regarding the code sample:
It's a sample showing 2 basic approaches to consume a ws without xmlports. Sample 2 shows the approach with xmlHttp object.
What happens if you use this? I think, at this stage it's not important how you got the xmlDoc (xmlport or not), just throw it to the send function an look what happens.
...
locautXmlHttp.send(locautXmlDoc);
locautXmlDoc.load(locautXmlHttp.responseXML);
locautXmlDoc.save('C:\temp.xml');
IF locautXmlHttp.status = 200 THEN
...
If you get something in c:\temp.xml, you are ready to analyze the error in an easier way. I have done some ws integration, the customer has the option to save the sent/received xml data when an error occurs.
Hope this helps
Thomas0 -
ta5 wrote:Hi Kisu
Regarding the code sample:
It's a sample showing 2 basic approaches to consume a ws without xmlports. Sample 2 shows the approach with xmlHttp object.
What happens if you use this? I think, at this stage it's not important how you got the xmlDoc (xmlport or not), just throw it to the send function an look what happens.
...
locautXmlHttp.send(locautXmlDoc);
locautXmlDoc.load(locautXmlHttp.responseXML);
locautXmlDoc.save('C:\temp.xml');
IF locautXmlHttp.status = 200 THEN
...
If you get something in c:\temp.xml, you are ready to analyze the error in an easier way. I have done some ws integration, the customer has the option to save the sent/received xml data when an error occurs.
Hope this helps
Thomas
Returns temp.xml that is 0kB
Status is 200K.S.0 -
:-k
Can you check with the provider of the service? They probably have a log to see what is going on on the service.
Thoams0 -
Kisu wrote:ta5 wrote::-k
Can you check with the provider of the service? They probably have a log to see what is going on on the service.
Thoams
I'm one step a head
already emailed them, waiting response.
Okay problem solved, was sending the request to wrong address, customer just wasnt sure which was the right one #-o
Solved now, cheers for all help :thumbsup:K.S.0 -
Hmm I pretty much got all thigs sorted for http request but in the end I got to another problem.
I might be mixing up the terms, still I've tried bunch of things and did not get it working.
From the webservice I'm still getting error that parameter is not valid: method: acceptable parameters are: add and edit.
Soo it seems I'd need to pass parameter method=add when POST:ing to the webservice but on XML DOM I cant find how to pass it during the send.
I tried to add header method with value add, but it was not that and also tried to add the element on xml port which didnt help either.
And 3rdly I tried to call the OPEN function like this
XmlHttp.open('POST', Url, FALSE, 'method=add');
and
XmlHttp.open('ADD', Url, FALSE);
but neither worked, so I'm a little stuck where to add that parameter. :-k
Any help with this would be appreciated
Edit:
Customer says the parameter method with value add should be within the query string :shock:K.S.0 -
Hi Kisu
Try this the setRequestHeader method:xmlHTTPConn.setRequestHeader(myProperty,myValue)
Hope this helps.
Thomas0 -
ta5 wrote:Hi Kisu
Try this the setRequestHeader method:xmlHTTPConn.setRequestHeader(myProperty,myValue)
Hope this helps.
Thomas
Heyas, nope it was not header method as I said previous post.
I got it working putting the method on the url after question mark
XmlHttp.open('POST', Url + '?method=add', FALSE); \:D/K.S.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions