Deserializing SOAP Response

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Wilhelm

    #1

    Deserializing SOAP Response

    Hi!

    I have a Problem understanding the deserialisation of SOAP-Responses.

    The "normal" way, calling a XML WebService is to use WSDL
    1) Send Request
    2) Get SOAP-Response
    3) With Informations out of WSDL transform the SOAP-Response to an Object.
    Let us call it "Customer".

    So far, so good. But in my Szenario, I have no WSDL. The Responses of the
    Services I'm talking with are high dynamical, e.g. sometimes a Customer ist
    returned, the next Time an Invoice.

    My purpose now is to deserialize the SOAP-Response on my own.
    I.e. if the SOAP-Response carries two integeres and one string, then I want
    that the SOAPCaller to return a Hashtable with the name of the Attributes
    and their values in the according type.

    Let's look on this simple SOAP-Response

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
    SOAP-ENV:encodingSty le="http://schemas.xmlsoap .org/soap/encoding/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap .org/soap/encoding/"
    xmlns:xsi="http ://www.w3.org/1999/XMLSchema-instance"
    xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/"
    xmlns:xsd3="htt p://www.w3.org/2001/XMLSchema"
    xmlns:xsd="http ://www.w3.org/1999/XMLSchema">
    <SOAP-ENV:Body>
    <ns1:getIdentDa taByIdResponse xmlns:ns1="http ://xxxxx/userdaten"
    SOAP-ENC:root="1">
    <IdentData>
    <tel xsi:null="1"/>
    <last_logon xsi:type="xsd3: dateTime">2004-05-06T11:01:30Z</last_logon>
    <lastname xsi:type="xsd:s tring">Test</nachname>
    <firstname xsi:type="xsd:s tring">CAT</vorname>
    <use_external_e mail xsi:type="xsd:i nteger">0</use_external_em ail>
    </IdentData>
    </ns1:getIdentDat aByIdResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    Out of this I want to create a Hashtable with
    tel: null (object)
    last_logon: 2004-05-06T11:01:30Z (DateTime)
    lastname: Test (string)
    firstname: CAT (string)
    use_external_em ail: 0 (integer)

    Is there some way to do this, without implementing all SOAP-Types on my own.
    In the easiest way I would wish to have an Attribute in the class
    SOAPResponse called "Value" of type Object.

    Thank you very much,
    Christian


  • Dino Chiesa [Microsoft]

    #2
    Re: Deserializing SOAP Response


    "Christian Wilhelm" <ch.wilhelm@big foot.de> wrote in message
    news:2vu0hdF2pi 95pU1@uni-berlin.de...
    [color=blue]
    > So far, so good. But in my Szenario, I have no WSDL. The Responses of the
    > Services I'm talking with are high dynamical, e.g. sometimes a Customer
    > ist
    > returned, the next Time an Invoice.
    >[/color]

    WSDL does not preclude what you describe.
    If there is no WSDL, then it is not web services. Why not write a WSDL and
    use it?

    The tools that come with .NET (eg, wsdl.exe) assume you want to return a
    particular kind of object, but in fact the return type could vary.

    There is nothing that prevents you from writing your own client-side proxy
    class, rather than using the class generated by wsdl.exe. I can imagine
    client-side web methods like

    Customer Method1Customer (arg1, arg2)
    Invoice Method1Invoice( arg1, arg2...)
    ..

    all of which call the same server-side method?

    [color=blue]
    > My purpose now is to deserialize the SOAP-Response on my own.
    > I.e. if the SOAP-Response carries two integeres and one string, then I
    > want
    > that the SOAPCaller to return a Hashtable with the name of the Attributes
    > and their values in the according type.
    >
    > Let's look on this simple SOAP-Response
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <SOAP-ENV:Envelope
    > SOAP-ENV:encodingSty le="http://schemas.xmlsoap .org/soap/encoding/"
    > xmlns:SOAP-ENC="http://schemas.xmlsoap .org/soap/encoding/"
    > xmlns:xsi="http ://www.w3.org/1999/XMLSchema-instance"
    > xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/"
    > xmlns:xsd3="htt p://www.w3.org/2001/XMLSchema"
    > xmlns:xsd="http ://www.w3.org/1999/XMLSchema">
    > <SOAP-ENV:Body>
    > <ns1:getIdentDa taByIdResponse xmlns:ns1="http ://xxxxx/userdaten"
    > SOAP-ENC:root="1">
    > <IdentData>
    > <tel xsi:null="1"/>
    > <last_logon xsi:type="xsd3: dateTime">2004-05-06T11:01:30Z</last_logon>
    > <lastname xsi:type="xsd:s tring">Test</nachname>
    > <firstname xsi:type="xsd:s tring">CAT</vorname>
    > <use_external_e mail xsi:type="xsd:i nteger">0</use_external_em ail>
    > </IdentData>
    > </ns1:getIdentDat aByIdResponse>
    > </SOAP-ENV:Body>
    > </SOAP-ENV:Envelope>
    >
    > Out of this I want to create a Hashtable with
    > tel: null (object)
    > last_logon: 2004-05-06T11:01:30Z (DateTime)
    > lastname: Test (string)
    > firstname: CAT (string)
    > use_external_em ail: 0 (integer)
    >[/color]

    I don't understand why you would do this. Why not use the tools to do what
    they do automatically? Why not use WSDL to do this for you?

    -Dino


    Comment

    • Christian Wilhelm

      #3
      Re: Deserializing SOAP Response

      Hi Dino,

      thank you for your Response. The answer is very simple: my Client uses SOAP
      to send a Request to a multitude of Servers and gets back a SOAP Response.
      But the Server my Client ist talking with are no XML WebServices, especially
      they don't provide WSDLs. Even worse: The Response of one and the same
      Method is changing from Request to Request.

      The only purpose of my Client is to present the Response of the Server.
      Sometimes one Value of the Response must be read and executed in another
      Query. Because of this, I wish an object oriented approach.

      In the meantime I have found a Method, which exactly does this for me. It is
      * object
      System.Runtime. Serialization.F ormatters.Soap. SoapFormatter.D eserialize(IO.S t
      ream stream)

      Now I have a few problems concerning xsd-Namespaces, but I think I can
      handle it on my own.

      Just one more Question:
      * Does someone know a Pendant to SoapFormatter in Java?

      Regards,
      Christian


      "Dino Chiesa [Microsoft]" <dinoch@online. microsoft.com> schrieb im
      Newsbeitrag news:ehpYRhAzEH A.2600@TK2MSFTN GP09.phx.gbl...[color=blue]
      >
      > "Christian Wilhelm" <ch.wilhelm@big foot.de> wrote in message
      > news:2vu0hdF2pi 95pU1@uni-berlin.de...
      >[color=green]
      > > So far, so good. But in my Szenario, I have no WSDL. The Responses of[/color][/color]
      the[color=blue][color=green]
      > > Services I'm talking with are high dynamical, e.g. sometimes a Customer
      > > ist
      > > returned, the next Time an Invoice.
      > >[/color]
      >
      > WSDL does not preclude what you describe.
      > If there is no WSDL, then it is not web services. Why not write a WSDL[/color]
      and[color=blue]
      > use it?
      >
      > The tools that come with .NET (eg, wsdl.exe) assume you want to return a
      > particular kind of object, but in fact the return type could vary.
      >
      > There is nothing that prevents you from writing your own client-side proxy
      > class, rather than using the class generated by wsdl.exe. I can imagine
      > client-side web methods like
      >
      > Customer Method1Customer (arg1, arg2)
      > Invoice Method1Invoice( arg1, arg2...)
      > ..
      >
      > all of which call the same server-side method?
      >
      >[color=green]
      > > My purpose now is to deserialize the SOAP-Response on my own.
      > > I.e. if the SOAP-Response carries two integeres and one string, then I
      > > want
      > > that the SOAPCaller to return a Hashtable with the name of the[/color][/color]
      Attributes[color=blue][color=green]
      > > and their values in the according type.
      > >
      > > Let's look on this simple SOAP-Response
      > >
      > > <?xml version="1.0" encoding="UTF-8"?>
      > > <SOAP-ENV:Envelope
      > > SOAP-ENV:encodingSty le="http://schemas.xmlsoap .org/soap/encoding/"
      > > xmlns:SOAP-ENC="http://schemas.xmlsoap .org/soap/encoding/"
      > > xmlns:xsi="http ://www.w3.org/1999/XMLSchema-instance"
      > > xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/"
      > > xmlns:xsd3="htt p://www.w3.org/2001/XMLSchema"
      > > xmlns:xsd="http ://www.w3.org/1999/XMLSchema">
      > > <SOAP-ENV:Body>
      > > <ns1:getIdentDa taByIdResponse xmlns:ns1="http ://xxxxx/userdaten"
      > > SOAP-ENC:root="1">
      > > <IdentData>
      > > <tel xsi:null="1"/>
      > > <last_logon xsi:type="xsd3: dateTime">2004-05-06T11:01:30Z</last_logon>
      > > <lastname xsi:type="xsd:s tring">Test</nachname>
      > > <firstname xsi:type="xsd:s tring">CAT</vorname>
      > > <use_external_e mail xsi:type="xsd:i nteger">0</use_external_em ail>
      > > </IdentData>
      > > </ns1:getIdentDat aByIdResponse>
      > > </SOAP-ENV:Body>
      > > </SOAP-ENV:Envelope>
      > >
      > > Out of this I want to create a Hashtable with
      > > tel: null (object)
      > > last_logon: 2004-05-06T11:01:30Z (DateTime)
      > > lastname: Test (string)
      > > firstname: CAT (string)
      > > use_external_em ail: 0 (integer)
      > >[/color]
      >
      > I don't understand why you would do this. Why not use the tools to do[/color]
      what[color=blue]
      > they do automatically? Why not use WSDL to do this for you?
      >
      > -Dino
      >
      >[/color]


      Comment

      • Dino Chiesa [Microsoft]

        #4
        Re: Deserializing SOAP Response

        > Just one more Question:[color=blue]
        > * Does someone know a Pendant to SoapFormatter in Java?
        >[/color]

        I think it depends on the SOAP toolkit you are using on the Java side.
        There are so many (Sun's JWSDP, Systinet, TME Glue, Apache AXIS, and so on)


        Comment

        • Christian Wilhelm

          #5
          Re: Deserializing SOAP Response

          Hi Dino,

          thank you very much for the Pointers, I'll be looking at them.

          Thank you,
          Christian

          "Dino Chiesa [Microsoft]" <dinoch@online. microsoft.com> schrieb im
          Newsbeitrag news:ulf7toMzEH A.2568@TK2MSFTN GP11.phx.gbl...[color=blue][color=green]
          > > Just one more Question:
          > > * Does someone know a Pendant to SoapFormatter in Java?
          > >[/color]
          >
          > I think it depends on the SOAP toolkit you are using on the Java side.
          > There are so many (Sun's JWSDP, Systinet, TME Glue, Apache AXIS, and so[/color]
          on)[color=blue]
          >
          >[/color]


          Comment

          Working...