How to extract xml-content from the soap-answer

RotbaerchiRotbaerchi Member Posts: 8
Hi,

I search for a solution for the following problem.

I consume a webservices via SOAP with the xmlhttprequest ('Microsoft XML, v6.0'.XMLHTTP60). The output, the answer of the webservice, of the responseXML-function is a complete SOAP-Message with the xml-message inside the body.

But, how can I extract this body from the hole SOAP to work with the xml-answer itselfs? I have the problem, that I cannot separate the xml from the soap with the MSXMLDom to have this xml in a node... So it is not possible to get the values of the other nodes...

Does anyone did somethink like that?

Thank´s
Mathias

Comments

  • DogmatikDogmatik Member Posts: 2
    I'm doing something similar... using the soaprequest to send the message, but i'm having the same problem of trying to use the results that are wrapped in the soap response.

    Here is what i'm trying:
    XmlDoc.load(SoapHttpconn.OutputStream);
    CurrNode := XmlDoc.selectSingleNode('//GetOrdResponse/GetOrdResult');
    XmlDoc2.loadXML(CurrNode.text);
    

    In my case the result from the webservice is a full xml document, and when i try to call the [CurrNode.text] I get the error 'The length of the string exceeds the size of the string buffer.'

    And as I just found that this error can be solved using this http://www.mibuso.com/forum/viewtopic.php?t=13161

    This should work for you as it does for me.

    /dog
  • RotbaerchiRotbaerchi Member Posts: 8
    Yes, the node.text has a max. length about 250 signs, I think...

    The answers from the webservices are much longer...

    I hoped, that there is a possibility like a function in the msxmldom, which can separate the content from the soap-information automaticly, as you tried it.

    Otherwise it has do be possible to get the node <content>xml-message</content> within the xml-data. And here I have the problem, that there is a namespace prefix for the hole document like:

    <nsprefix:nodename>

    So you have do call the function selectsinglenode with a prefix to get the node like:

    xmldomnode1 := xmldomenode.selectsinglenode('nodename'), but right is something like that
    xmldomnode1 := xmldomenode.selectsinglenode('prefix:nodename'), but this doesn´t work too, because of the missing prefix. So I tried to set a prefix to the xmldomdoc, from which the node is a child with:

    XMLDomDoc.setProperty('',''); but this doesn´t work too...

    Any ideas?

    Thank´s
    Mathias
  • DenSterDenSter Member Posts: 8,305
    Have you tried using the Load method (as opposed to the LoadXML method)? You should be able to load a node object into another DOM object.
  • RotbaerchiRotbaerchi Member Posts: 8
    Yes, I did, but this method returns also a string. And this is to long to work with it, like the currnode.text...

    Mathias...
  • ara3nara3n Member Posts: 9,256
    Rotbaerchi. The 250 char limit is a horrible horrrible limitation of navision. They haven't fixed for years. Two solutions.
    Write a wrapper dll file.

    Write the xml doc into file and read the file.

    xmldom.save('c:\temp.xml');
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,305
    here's a thought.. try loading the value into an instream, save that to a BLOB field, then load it into an outstream and use the Load method of the MSDOM object. I have no idea if it'll work, but it's worth a shot..
  • ara3nara3n Member Posts: 9,256
    Navision Streams are not compatible with xmldom streams. So it won't compile.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • RotbaerchiRotbaerchi Member Posts: 8
    Thanks to all,

    that are good ideas, and I tried all these before, but nothing works correct. Interesting is the "saving to file" - method. If you save the domdoc.element to a file and this as the textformat, than you are able to get the content from the soap. With the saving and the loading into the domdoc after that, it is possible to read the content and this as literal, and it works for short texts, but not for documents ...

    But this is not a solution for the using of a webservice, because the idea is, to go away from the saving and work with the domdoc anytime in the navisionobjects. So I tried the streammethod, which doesn´t work (as ara3n mentioned) because the known problem.

    Now I go from node to node to get the content, but at the end I´ll have the encoding problem. Do anyone have a new Idea?

    I think that the import is possible, because the "dirty" way :wink: with the saving works...

    Mathias
  • RallnusRallnus Member Posts: 79
    Did you find the solution?
    Rallnus (Yamaha FJ1200 - '89 / 25th anniversary was great!)
  • mandykmandyk Member Posts: 57
    Hi Rotbaerchi,
    Not too sure if you still have interest with the matter but you can visit my blog article below:
    http://mibuso.com/blogs/mandyk/2009/06/ ... xml-format

    In short, I have developed COM wrapper dll to extract and upload big value of XML node to the Stream data type.

    Cheers
  • rmv_RUrmv_RU Member Posts: 119
    Rotbaerchi wrote:
    Hi,
    But, how can I extract this body from the hole SOAP to work with the xml-answer itselfs? I have the problem, that I cannot separate the xml from the soap with the MSXMLDom to have this xml in a node... So it is not possible to get the values of the other nodes...
    Hi.
    You should use xmlTextNode to read embedded data.
    Look at this How to read XML data where all fields in single string ?, Error while sending URL via HTTP POST using XMLHTTP and this Error When Create & Load MSXML DOM Document. topics.
    Looking for part-time work.
    Nav, T-SQL.
Sign In or Register to comment.