RosesDurden / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

Client request namespace issue #138

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Calling a method on our internal service results in a `SoapFault: S:Server: 
java.lang.NullPointerException`.  The server logs show the NullPointerException 
is thrown as the appId/address parameters are passed with the wrong namespace.

{{{
client = SoapClient(wsdl=<uri to WSDL>) #Note imports XSD
appId='blah'
address={'streetLine':'1 Some St',
         'suburb':'Some Suburb',
         'state':'SS',
         'postcode':'1234'
        }

response=client.geocodeAddress(appId=appId,address=address)
#SoapFault: S:Server: java.lang.NullPointerException
}}}

I've attached the WSDL and XSD from the server.

The xml generated internally by the pysimplesoap client is:

{{{<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Header/>
  <soap:Body>
    <geocodeAddressRequest xmlns="http://geocodegateway">
      <appId>test</appId>
      <address>
        <streetLine>1 Some St</streetLine>
        <suburb>Some Suburb</suburb>
        <state>SS</state>
        <postcode>1234</postcode>
      </address>
    </geocodeAddressRequest>
  </soap:Body>
</soap:Envelope>
}}}

If I send the following raw xml via the `SoapClient.send` method, I get the 
expected response.

{{{<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Header />
  <soap:Body>
    <nsblah:geocodeAddressRequest xmlns:nsblah="http://geocodegateway">
      <appId>test</appId>
      <address>
        <streetLine>1 Some St</streetLine>
        <suburb>Some Suburb</suburb>
        <state>SS</state>
        <postcode>1234</postcode>
      </address>
    </nsblah:geocodeAddressRequest>
  </soap:Body>
</soap:Envelope>

<!-- the following also works:
     ...
     <geocodeAddressRequest xmlns="http://geocodegateway">
      <appId xmlns="">test</appId>
      <address xmlns="">
        <streetLine xmlns="">
        etc...
-->
}}}

Original issue reported on code.google.com by lukepinn...@gmail.com on 27 Feb 2014 at 2:46

Attachments:

GoogleCodeExporter commented 8 years ago
Could you test:

client = SoapClient(wsdl="issue138.wsdl", trace=True, ns="ns") 

ns="ns" should generate the following xml:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope 
xmlns:ns="http://geocodegateway" 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
    <ns:geocodeAddressRequest>
    <appId>blah</appId><address><streetLine xmlns="http://geocodegateway">1 Some St</streetLine><suburb xmlns="http://geocodegateway">Some Suburb</suburb><state xmlns="http://geocodegateway">SS</state><postcode xmlns="http://geocodegateway">1234</postcode></address></ns:geocodeAddressRequest>
</soapenv:Body>
</soapenv:Envelope

It seems that is not honoring the qualified attribute value in 
elementFormDefault, so that topic needs some debugging 

I don't have free time right now to review this (if this is urgent, please 
contact me via email), but you can check in client.py and simplexml.py if it is 
handled ok and/or trying to tweak it

Original comment by reingart@gmail.com on 27 Feb 2014 at 5:50

GoogleCodeExporter commented 8 years ago
Yes, passing an ns parameter results in the xml format as per your comment.  
The server still throws the NullPointerException as the string elements 
(<suburb> etc...) of the address type have xmlns="http://geocodegateway".

Thanks

Original comment by lukepinn...@gmail.com on 27 Feb 2014 at 10:40