Xml file with xmlhttp request

KisuKisu 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
K.S.

Answers

  • ara3nara3n Member Posts: 9,256
    yes. Read my first blog. It uses xmlport as example

    http://mibuso.com/blogs/ara3n/2008/03/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • KisuKisu Member Posts: 381
    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 OK
    K.S.
  • ta5ta5 Member Posts: 1,164
    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
    Thomas
  • KisuKisu Member Posts: 381
    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
    K.S.
  • ta5ta5 Member Posts: 1,164
    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
  • KisuKisu Member Posts: 381
    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.
  • KisuKisu Member Posts: 381
    Hmm and if I try to get the response as txt it overflows text buffer.
    K.S.
  • ta5ta5 Member Posts: 1,164
    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
  • KisuKisu Member Posts: 381
    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 200
    K.S.
  • ta5ta5 Member Posts: 1,164
    :-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
  • KisuKisu Member Posts: 381
    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.
    K.S.
  • KisuKisu Member Posts: 381
    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.
  • KisuKisu Member Posts: 381
    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.
  • ta5ta5 Member Posts: 1,164
    Hi Kisu

    Try this the setRequestHeader method:
    xmlHTTPConn.setRequestHeader(myProperty,myValue)
    

    Hope this helps.
    Thomas
  • KisuKisu Member Posts: 381
    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.
Sign In or Register to comment.