Submitting an xml document to a web service

Discussion in 'ASP .Net Web Services' started by Keith Chadwick, Nov 27, 2004.

  1. Wonder if someone can get me on the right track. I have a web service that
    returns the xml representation of some data. This returned data is loaded
    in the client (i.e. 6) into a msxml4 object. The data is then rendered to
    html with a xsl transformation client side. This works great and how things
    will stay. Now I need to get the data the other way to a web service.

    When the user clicks on Save the client side xml is updated with the values
    they have changed. I then need to post this back to another web service
    that will expect this data. Now obviously I can not simply pas the xml as
    string on the querystring because you run into encoding problems if the user
    has entered in & > or < values for example, and yes I have to allow for
    these.

    So my question is how to send the xml back to a web service via Jscript and
    get a xml response back from the service? Do I need to wrap it in a soap
    package or something similar?

    Any help would be appreciated.

    Cheers
    Keith
    Keith Chadwick, Nov 27, 2004
    #1
    1. Advertising

  2. Keith Chadwick wrote:


    > So my question is how to send the xml back to a web service via Jscript and
    > get a xml response back from the service? Do I need to wrap it in a soap
    > package or something similar?


    You can do a HTTP POST request where the XML is sent in the body of the
    HTTP request:
    var httpRequest = new ActiveXObject('Msxml2.XMLHTTP.4.0');
    httpRequest.open('POST', 'whatever.asp', true);
    httpRequest.onreadystatechange = function () {
    if (httpRequest.readyState == 4) {
    // process httpRequest.responseXML here
    }
    };
    httpRequest.send(putMsxml2.DOMDocument.4.0Here);

    If you really want to send the data to a web service then of course you
    might need to use SOAP, then the web service behaviour should help you
    on the client, seach http://msdn.microsoft.com/ for that.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 28, 2004
    #2
    1. Advertising

  3. Thanks Martin,

    I got as far as you mentioned last night but my problem is getting my web
    service to accept the incomming data. Nothing like a weekend learner curve!

    Cheer

    "Martin Honnen" <> wrote in message
    news:...
    >
    >
    > Keith Chadwick wrote:
    >
    >
    >> So my question is how to send the xml back to a web service via Jscript
    >> and get a xml response back from the service? Do I need to wrap it in a
    >> soap package or something similar?

    >
    > You can do a HTTP POST request where the XML is sent in the body of the
    > HTTP request:
    > var httpRequest = new ActiveXObject('Msxml2.XMLHTTP.4.0');
    > httpRequest.open('POST', 'whatever.asp', true);
    > httpRequest.onreadystatechange = function () {
    > if (httpRequest.readyState == 4) {
    > // process httpRequest.responseXML here
    > }
    > };
    > httpRequest.send(putMsxml2.DOMDocument.4.0Here);
    >
    > If you really want to send the data to a web service then of course you
    > might need to use SOAP, then the web service behaviour should help you on
    > the client, seach http://msdn.microsoft.com/ for that.
    >
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
    Keith Chadwick, Nov 28, 2004
    #3
  4. Keith Chadwick

    Dan Rogers Guest

    Hi Keith,

    I posted some answers to your original questions on your original post.

    Regards
    Dan Rogers
    Microsoft Corporation
    --------------------
    >From: "Keith Chadwick" <>
    >References: <>

    <>
    >Subject: Re: Submitting an xml document to a web service
    >Date: Sun, 28 Nov 2004 09:28:59 -0500
    >Lines: 40
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >X-RFC2646: Format=Flowed; Response
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >NNTP-Posting-Host: ottawa-hs-64-26-156-220.s-ip.magma.ca 64.26.156.220
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA06.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08
    phx.gbl!TK2MSFTNGP09.phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:26840
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >Thanks Martin,
    >
    >I got as far as you mentioned last night but my problem is getting my web
    >service to accept the incomming data. Nothing like a weekend learner curve!
    >
    >Cheer
    >
    >"Martin Honnen" <> wrote in message
    >news:...
    >>
    >>
    >> Keith Chadwick wrote:
    >>
    >>
    >>> So my question is how to send the xml back to a web service via Jscript
    >>> and get a xml response back from the service? Do I need to wrap it in

    a
    >>> soap package or something similar?

    >>
    >> You can do a HTTP POST request where the XML is sent in the body of the
    >> HTTP request:
    >> var httpRequest = new ActiveXObject('Msxml2.XMLHTTP.4.0');
    >> httpRequest.open('POST', 'whatever.asp', true);
    >> httpRequest.onreadystatechange = function () {
    >> if (httpRequest.readyState == 4) {
    >> // process httpRequest.responseXML here
    >> }
    >> };
    >> httpRequest.send(putMsxml2.DOMDocument.4.0Here);
    >>
    >> If you really want to send the data to a web service then of course you
    >> might need to use SOAP, then the web service behaviour should help you

    on
    >> the client, seach http://msdn.microsoft.com/ for that.
    >>
    >>
    >> --
    >>
    >> Martin Honnen
    >> http://JavaScript.FAQTs.com/

    >
    >
    >
    Dan Rogers, Nov 29, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Prichard
    Replies:
    0
    Views:
    715
    Tony Prichard
    Dec 12, 2003
  2. Manish Hatwalne
    Replies:
    1
    Views:
    392
    Martin Honnen
    Jul 13, 2004
  3. Robson Siqueira
    Replies:
    0
    Views:
    327
    Robson Siqueira
    Apr 18, 2007
  4. GMartin
    Replies:
    2
    Views:
    298
    GMartin
    Feb 11, 2008
  5. Robson Siqueira

    Infopath 2003 form not properly submitting data to Web Service

    Robson Siqueira, Apr 18, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    100
    Robson Siqueira
    Apr 18, 2007
Loading...

Share This Page