Is there a SOAP module that can do this...?

Discussion in 'Python' started by thebjorn, Sep 10, 2008.

  1. thebjorn

    thebjorn Guest

    I've been trying to use SOAPpy and ZSI (with and without the use of
    wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic
    server(?) in front of some enterprise java bean) and not having much
    luck. I got them to send me an example of what the bytes on the wire
    are supposed to look like (attached below), and I got it to "work" by
    going lo-tech:

    cn = httplib.HTTPSConnection('test.xx.no',443)
    cn.putrequest("POST", "/service/url")
    cn.putheader("Host", "test.xx.no")
    cn.putheader("Content-type", 'text/xml; charset="UTF-8"')
    cn.putheader("Content-length", "%d" % len(soap_message))
    cn.putheader("SOAPAction", '""')
    cn.endheaders()
    cn.send(soap_message)

    Is there a better way to do this? Can it be done with any of the
    Python SOAP libraries?

    Bjorn

    soap message follows:

    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <Header xmlns="http://schemas.xmlsoap.org/soap/envelope/" />
    <env:Body>
    <submitMessage xmlns="http://no/brreg/BReMS/WebService/services">
    <cpaid>y111</cpaid>
    <securityKey>y222</securityKey>
    <message><![CDATA[<?xml version='1.0' encoding='ISO-8859-1'?>
    <SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    <SOAP:Header xmlns:eb='http://www.oasis-open.org/committees/ebxml-msg/
    schema/msg-header-2_0.xsd'>
    <eb:MessageHeader eb:id='1' eb:version='2.0' SOAP:mustUnderstand='1'>
    <eb:From>
    <eb:partyId eb:type='orgnr-submitter'>x111</eb:partyId>
    <eb:partyId eb:type='orgnr-caseworker'>x222</eb:partyId>
    <eb:Role>Submitter</eb:Role>
    </eb:From>
    <eb:To>
    <eb:partyId eb:type='orgnr-registrator'>x111</eb:partyId>
    <eb:Role>Registrator</eb:Role>
    </eb:To>
    <eb:CPAId>y111</eb:CPAId>
    <eb:ConversationId>ccd6dc26-836f-4768-8d28-5d46a872b9e8</
    eb:ConversationId>
    <eb:Service eb:type='lockup'>x444</eb:Service>
    <eb:Action>appendMessage</eb:Action>
    <eb:MessageData>
    <eb:MessageId>ccd6dc26-836f-4768-8d28-5d46a872b9e8</eb:MessageId>
    <eb:Timestamp>23.09.2006</eb:Timestamp>
    </eb:MessageData>
    <eb:Description xml:lang='no'></eb:Description>
    </eb:MessageHeader>
    </SOAP:Header>
    <SOAP:Body>
    <LegacyData>
    <JegerproveInn xsi:noNamespaceSchemaLocation="JegerproveInn.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Arrangor>
    <ArrangorId>3</ArrangorId>
    <ArrangorNavn>
    <Navn1>BBB</Navn1>
    <Navn5></Navn5>
    </ArrangorNavn>
    <PersonNavn>
    <Fornavn>CCC</Fornavn>
    <Etternavn>DDD</Etternavn>
    </PersonNavn>
    <Kommunenr>9999</Kommunenr>
    <Telefon>12345678</Telefon>
    <Epost></Epost>
    </Arrangor>
    </JegerproveInn></LegacyData></SOAP:Body></SOAP:Envelope>]]>
    </message>
    </submitMessage>
    </env:Body>
    </env:Envelope>
     
    thebjorn, Sep 10, 2008
    #1
    1. Advertising

  2. On Sep 10, 1:23 pm, thebjorn <>
    wrote:
    > I've been trying to use SOAPpy and ZSI (with and without the use of
    > wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic
    > server(?) in front of some enterprise java bean) and not having much
    > luck.  I got them to send me an example of what the bytes on the wire
    > are supposed to look like (attached below), and I got it to "work" by
    > going lo-tech:
    >

    If you are willing to go low tech you can try
    http://effbot.org/downloads/#elementsoap

    But before you do that try:
    https://fedorahosted.org/suds
    It is actively maintained and holds a lot of promise.
    In my testing it knew how to connect to Sharepoint as well
    as WebLogic exposed services.

    Waldemar
     
    Waldemar Osuch, Sep 10, 2008
    #2
    1. Advertising

  3. thebjorn

    thebjorn Guest

    On Sep 10, 9:44 pm, Waldemar Osuch <> wrote:
    > On Sep 10, 1:23 pm, thebjorn <>
    > wrote:> I've been trying to use SOAPpy and ZSI (with and without the use of
    > > wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic
    > > server(?) in front of some enterprise java bean) and not having much
    > > luck.  I got them to send me an example of what the bytes on the wire
    > > are supposed to look like (attached below), and I got it to "work" by
    > > going lo-tech:

    >
    > If you are willing to go low tech you can tryhttp://effbot.org/downloads/#elementsoap
    >
    > But before you do that try:https://fedorahosted.org/suds
    > It is actively maintained and holds a lot of promise.
    > In my testing it knew how to connect to Sharepoint as well
    > as WebLogic exposed services.
    >
    > Waldemar


    Thanks for the info Waldemar. I'm looking into suds now, but there's
    something I'm having trouble wrapping my head around (xml isn't my
    usual territory, so this is perhaps obvious to someone...) This is
    what suds tells me:

    >>> print client

    suds ( version=0.2.9 )

    service ( InboundLegacyDataService )
    prefixes:
    ns0 = "http://no/brreg/BReMS/WebService/services"
    methods (2):
    getInfo()
    submitMessage(xs:string cpaid, xs:string securityKey,
    xs:string message, )
    types (4):
    submitMessage
    submitMessageResponse
    getInfo
    getInfoResponse

    The method I'm interested in is submitMessage and in particular the
    ``xs:string message`` parameter. I've been provided with three xsd
    files that I'm almost 100% sure defines the format of the xml in the
    message (it defines the JegerproveInn sub-structure), but it looks
    like that has to be wrapped in a SOAP:Envelope, including the <?xml..>
    declaration before being stuffed into the xs:string message parameter,
    before that in turn is wrapped in an env:Envelope... Am I on the right
    track?

    Another question: I'm assuming the xsd files can be used for more
    than documentation :) I've found the w3schools "Introduction to XML
    Schema" which I'm starting to read right now, however I haven't been
    able to google up any Python<->xsd "thingy" that looked promising
    (since I'm not sure what I'm looking for, this might not be a big
    surprise ;-) Is there such a "thingy"?

    Bjorn
     
    thebjorn, Sep 11, 2008
    #3
  4. thebjorn wrote:
    > I've been trying to use SOAPpy and ZSI (with and without the use of
    > wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic
    > server(?) in front of some enterprise java bean) and not having much
    > luck.


    Have you tried using soaplib? I find it very usable and from what I heard so
    far, a couple of other people also like it a lot better than ZSI.

    Stefan
     
    Stefan Behnel, Sep 11, 2008
    #4
  5. On Sep 11, 3:50 am, thebjorn <>
    wrote:
    > On Sep 10, 9:44 pm, Waldemar Osuch <> wrote:
    >
    >
    >
    > > On Sep 10, 1:23 pm, thebjorn <>
    > > wrote:> I've been trying to use SOAPpy and ZSI (with and without the use of
    > > > wsdl2py) to communicate with a SOAP server (looks like it's a WebLogic
    > > > server(?) in front of some enterprise java bean) and not having much
    > > > luck.  I got them to send me an example of what the bytes on the wire
    > > > are supposed to look like (attached below), and I got it to "work" by
    > > > going lo-tech:

    >
    > > If you are willing to go low tech you can tryhttp://effbot.org/downloads/#elementsoap

    >
    > > But before you do that try:https://fedorahosted.org/suds
    > > It is actively maintained and holds a lot of promise.
    > > In my testing it knew how to connect to Sharepoint as well
    > > as WebLogic exposed services.

    >
    > > Waldemar

    >
    > Thanks for the info Waldemar. I'm looking into suds now, but there's
    > something I'm having trouble wrapping my head around (xml isn't my
    > usual territory, so this is perhaps obvious to someone...) This is
    > what suds tells me:
    >
    > >>> print client

    >
    > suds ( version=0.2.9 )
    >
    > service ( InboundLegacyDataService )
    >         prefixes:
    >                 ns0 = "http://no/brreg/BReMS/WebService/services"
    >         methods (2):
    >                 getInfo()
    >                 submitMessage(xs:string cpaid, xs:string securityKey,
    > xs:string message, )
    >         types (4):
    >                 submitMessage
    >                 submitMessageResponse
    >                 getInfo
    >                 getInfoResponse
    >
    > The method I'm interested in is submitMessage and in particular the
    > ``xs:string message`` parameter.  I've been provided with three xsd
    > files that I'm almost 100% sure defines the format of the xml in the
    > message (it defines the JegerproveInn sub-structure), but it looks
    > like that has to be wrapped in a SOAP:Envelope, including the <?xml..>
    > declaration before being stuffed into the xs:string message parameter,
    > before that in turn is wrapped in an env:Envelope... Am I on the right
    > track?
    >


    After you figure out how the message should look like, pass it with
    the
    rest of the parameters to the submitMessage.
    "suds" should take care of the rest. Like wrap everything
    into Envelope, send the request and parse response.

    If you have to build XML from python let me point you to very useful
    http://svn.effbot.python-hosting.com/stuff/sandbox/elementlib/builder.py
    or
    http://codespeak.net/lxml/api/lxml.builder.ElementMaker-class.html

    > Another question:  I'm assuming the xsd files can be used for more
    > than documentation :)  I've found the w3schools "Introduction to XML
    > Schema" which I'm starting to read right now, however I haven't been
    > able to google up any Python<->xsd "thingy" that looked promising
    > (since I'm not sure what I'm looking for, this might not be a big
    > surprise ;-)  Is there such a "thingy"?


    python<->xsd thingy you mention could be "lxml" library that is an
    implementation of ElementTree + "number of very useful extensions".
    Most of the time XSD is used to validate XML documents.
    http://codespeak.net/lxml/validation.html
     
    Waldemar Osuch, Sep 11, 2008
    #5
    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. Sham Ramakrishnan
    Replies:
    2
    Views:
    8,372
    Sham Ramakrishnan
    Jul 1, 2003
  2. mooseshoes

    To SOAP or Not To SOAP?

    mooseshoes, Sep 4, 2003, in forum: XML
    Replies:
    3
    Views:
    403
    Heinz Häberle
    Sep 21, 2003
  3. Nagesh
    Replies:
    2
    Views:
    9,401
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Aug 12, 2006
  4. comp.text.xml
    Replies:
    0
    Views:
    515
    comp.text.xml
    Sep 20, 2006
  5. Justin Wyllie
    Replies:
    5
    Views:
    242
    Peter Pan
    Jan 11, 2005
Loading...

Share This Page