KenyaDonDraper / pysimplesoap

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

raised SoapFault in some web service. #94

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
========================================================================
1. execute the following code.
# -*- coding: utf-8 -*-

import logging
import pysimplesoap.client

import pprint

def test_pysimplesoap():
    client = pysimplesoap.client.SoapClient(wsdl='http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?wsdl', trace=True)
    print dir(client)
    print client.namespace
    #pprint.pprint(client.services)

    ret = client.GetCitiesByCountry('korea')
    print ret

    print type(ret[0]), ret[0]

    for r in ret[0]:
        print r

if __name__ == "__main__":
    test_pysimplesoap()
========================================================================

What is the expected output? What do you see instead?
GetCitiesByCountry() is expected to return city names of korea.
But, SoapFault exception is raised.
========================================================================
Traceback (most recent call last):
  File "test_pysimplesoap.py", line 23, in <module>
    test_pysimplesoap()
  File "test_pysimplesoap.py", line 14, in test_pysimplesoap
    ret = client.GetCitiesByCountry('korea')
  File "C:\devtool\py27x86\lib\site-packages\pysimplesoap\client.py", line 147,in <lambda>
    return lambda *args, **kwargs: self.wsdl_call(attr,*args,**kwargs)
  File "C:\devtool\py27x86\lib\site-packages\pysimplesoap\client.py", line 331,in wsdl_call
    response = self.call(method, *params)
  File "C:\devtool\py27x86\lib\site-packages\pysimplesoap\client.py", line 219,in call
    raise SoapFault(unicode(response.faultcode), unicode(response.faultstring))
pysimplesoap.client.SoapFault: a:InternalServiceFault: The server was unable to
process the request due to an internal error.  For more information about the er
ror, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorA
ttribute or from the <serviceDebug> configuration behavior) on the server in ord
er to send the exception information back to the client, or turn on tracing as p
er the Microsoft .NET Framework 3.0 SDK documentation and inspect the server tra
ce logs.
========================================================================

What version of the product are you using? On what operating system?
os : windows 7 sp1 64bit
python : python 2.7.3 32bit
pysimplesoap : 1.07a (latest hg version)

Please provide any additional information below.
Below is trace log when SoapFault raised.
========================================================================
Importing schema http://www.restfulwebservices.net/ServiceContracts/2008/01 
from http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?xsd=xsd0
Importing schema http://schemas.microsoft.com/2003/10/Serialization/Arrays from 
http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?xsd=xsd2
Importing schema http://www.restfulwebservices.net/DataContracts/2008/01 from 
http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?xsd=xsd4
Importing schema http://GOTLServices.FaultContracts/2008/01 from 
http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?xsd=xsd3
Importing schema http://schemas.microsoft.com/2003/10/Serialization/ from 
http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?xsd=xsd1
['_SoapClient__call_headers', '_SoapClient__headers', '_SoapClient__ns', 
'_SoapClient__soap_ns', '_SoapClient__soap_server', '_SoapClient__xml', 
'__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', 
'__getattribute__', '__hash__', '__init__', '__module__', '__new__', 
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', 
'__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'action', 'cacert', 
'call', 'certssl', 'close', 'documentation', 'exceptions', 'get_operation', 
'help', 'http', 'http_headers', 'keyssl', 'location', 'namespace', 'send', 
'service_port', 'services', 'trace', 'wsdl_call', 'wsdl_parse', 'xml_request', 
'xml_response']
http://www.restfulwebservices.net/ServiceContracts/2008/01/Imports
--------------------------------------------------------------------------------
POST http://www.restfulwebservices.net/wcf/WeatherForecastService.svc
SOAPAction: "GetCitiesByCountry"
Content-length: 414
Content-type: text/xml; charset="UTF-8"

<?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>
    <GetCitiesByCountry xmlns="http://www.restfulwebservices.net/ServiceContracts/2008/01/Imports">
    <Country>korea</Country></GetCitiesByCountry>
</soap:Body>
</soap:Envelope>

status: 500
content-length: 734
x-powered-by: ASP.NET
server: Microsoft-IIS/7.0
date: Tue, 19 Feb 2013 08:53:17 GMT
content-type: text/xml; charset=utf-8
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode 
xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation
/dispatcher">
a:InternalServiceFault
</faultcode>
<faultstring xml:lang="en-US">
The server was unable to process the request due to an internal error.  
For more information about the error, either turn on 
IncludeExceptionDetailInFaults 
(either from ServiceBehaviorAttribute or from the &lt;serviceDebug&gt; 
configuration behavior) 
on the server in order to send the exception information back to the client, 
or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation 
and inspect the server trace logs.
</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
================================================================================

This web service works well with suds(https://fedorahosted.org/suds/).
========================================================================
# -*- coding: utf-8 -*-

import logging
import suds

def test_suds():
    logging.basicConfig(level=logging.INFO)
    logging.getLogger('suds.client').setLevel(logging.DEBUG)

    client = suds.client.Client('http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?wsdl')
    print client

    ret = client.service.GetCitiesByCountry('korea')
    print ret   

    print type(ret[0]), ret[0]

    for r in ret[0]:
        print r

if __name__ == "__main__":
    test_suds() 
========================================================================
========================================================================
DEBUG:suds.client:sending to 
(http://www.restfulwebservices.net/wcf/WeatherForecastService.svc)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
xmlns:ns0="http://www.restfulwebservices.net/ServiceContracts/2008/01" 
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:GetCitiesByCountry>
         <ns0:Country>korea</ns0:Country>
      </ns0:GetCitiesByCountry>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'"GetCitiesByCountry"', 
'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.client:http succeeded:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetCitiesByCountryResponse 
xmlns="http://www.restfulwebservices.net/ServiceContracts/2008/01">
<GetCitiesByCountryResult 
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:string>KWANGJU</a:string>
<a:string>KUNSAN</a:string>
<a:string>MOKPO</a:string>
.......
<a:string>PYONGYANG</a:string>
<a:string>UAMA</a:string>
<a:string>UIJU</a:string>
</GetCitiesByCountryResult>
</GetCitiesByCountryResponse>
</s:Body>
</s:Envelope>
========================================================================

Original issue reported on code.google.com by marun...@gmail.com on 19 Feb 2013 at 10:30

GoogleCodeExporter commented 9 years ago
I do more test.
And pysimplesoap.client.SoapClient with WSDL may have a bug to set the 
incorrect namespace.

Below is the generated xml by SoupUI.
========================================================================
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns="http://www.restfulwebservices.net/ServiceContracts/2008/01">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:GetCitiesByCountry>
         <!--Optional:-->         
         <ns:Country>korea</ns:Country>
      </ns:GetCitiesByCountry>
   </soapenv:Body>
</soapenv:Envelope>
========================================================================

I compare this xml code with my xml code.
And I found that pysimpleapi set the incorrect namespace.
The namespace may be 
"http://www.restfulwebservices.net/ServiceContracts/2008/01" not 
"http://www.restfulwebservices.net/ServiceContracts/2008/01/Imports".

Following code set the namespace to 
"http://www.restfulwebservices.net/ServiceContracts/2008/01" temporarily.
And works well.
========================================================================
# -*- coding: utf-8 -*-
import logging
import pysimplesoap.client
import pprint

def test_pysimplesoap():
    wsdl='http://www.restfulwebservices.net/wcf/WeatherForecastService.svc?wsdl'
    client = pysimplesoap.client.SoapClient(wsdl=wsdl, #soap_ns="soapenv",
        #ns="ns",
        #namespace="http://www.restfulwebservices.net/ServiceContracts/2008/01",
        trace=True)
    client.namespace="http://www.restfulwebservices.net/ServiceContracts/2008/01"
    ret = client.GetCitiesByCountry("KOREA")
    print ret

if __name__ == "__main__":
    test_pysimplesoap()
========================================================================
SOAPAction: "GetCitiesByCountry"
Content-length: 406
Content-type: text/xml; charset="UTF-8"

<?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>
    <GetCitiesByCountry xmlns="http://www.restfulwebservices.net/ServiceContracts/2008/01">
    <Country>KOREA</Country></GetCitiesByCountry>
</soap:Body>
</soap:Envelope>

status: 200
content-length: 1893
x-powered-by: ASP.NET
vary: Accept-Encoding
server: Microsoft-IIS/7.0
-content-encoding: gzip
date: Thu, 21 Feb 2013 08:42:34 GMT
content-type: text/xml; charset=utf-8
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><GetCiti
esByCountryResponse xmlns="http://www.restfulwebservices.net/ServiceContracts/20
08/01"><GetCitiesByCountryResult xmlns:a="http://schemas.microsoft.com/2003/10/S
erialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:stri
ng>KWANGJU</a:string><a:string>KUNSAN</a:string><a:string>MOKPO</a:string><a:str
ing>JHUNJU</a:string><a:string>YEOSU</a:string><a:string>CHUNCHON</a:string><a:s
tring>SOKCH'O</a:string><a:string>HEONGSUNG</a:string><a:string>INJAE</a:string>
<a:string>KWANDAERI</a:string><a:string>KANGNUNG</a:string><a:string>SAMCHOK</a:
string><a:string>WONJU</a:string><a:string>YANGKU</a:string><a:string>CHEJU</a:s
tring><a:string>CHINHAE</a:string><a:string>KIMHAE</a:string><a:string>CHEJU</a:
string><a:string>BUSAN</a:string><a:string>SACHON</a:string><a:string>ULSAN</a:s
tring><a:string>ASCOM CITY</a:string><a:string>UIJEONGBU</a:string><a:string>CHE
ONGOKRI</a:string><a:string>PAEKRYOUNGDO BEACH</a:string><a:string>KOREAN AIR FO
RCE HQ</a:string><a:string>PYONGTAEK</a:string><a:string>SUSAEK</a:string><a:str
ing>SEOUL EAST</a:string><a:string>KUNI</a:string><a:string>OSAN</a:string><a:st
ring>PAEKRYOUNGDO SITE</a:string><a:string>YEONGDONGRI</a:string><a:string>SEOUL
</a:string><a:string>TONGDUCHEON</a:string><a:string>YEOJU</a:string><a:string>S
UWON</a:string><a:string>SONG SAN-RI</a:string><a:string>SEOUL</a:string><a:stri
ng>ANDONG</a:string><a:string>CHUNGJU</a:string><a:string>TAEJON</a:string><a:st
ring>POHANG</a:string><a:string>KYUNGJU</a:string><a:string>TAEGU</a:string><a:s
tring>SANGJU</a:string><a:string>CHONGJU</a:string><a:string>YECHON</a:string><a
:string>HAMHUNG</a:string><a:string>KIMCHAEK</a:string><a:string>PYONGYANG</a:st
ring><a:string>UAMA</a:string><a:string>UIJU</a:string></GetCitiesByCountryResul
t></GetCitiesByCountryResponse></s:Body></s:Envelope>
================================================================================

{'GetCitiesByCountryResult': [{'string': u'KWANGJU'}, {'string': u'KUNSAN'}, {'s
tring': u'MOKPO'}, {'string': u'JHUNJU'}, {'string': u'YEOSU'}, {'string': u'CHU
NCHON'}, {'string': u"SOKCH'O"}, {'string': u'HEONGSUNG'}, {'string': u'INJAE'},
 {'string': u'KWANDAERI'}, {'string': u'KANGNUNG'}, {'string': u'SAMCHOK'}, {'st
ring': u'WONJU'}, {'string': u'YANGKU'}, {'string': u'CHEJU'}, {'string': u'CHIN
HAE'}, {'string': u'KIMHAE'}, {'string': u'CHEJU'}, {'string': u'BUSAN'}, {'stri
ng': u'SACHON'}, {'string': u'ULSAN'}, {'string': u'ASCOM CITY'}, {'string': u'U
IJEONGBU'}, {'string': u'CHEONGOKRI'}, {'string': u'PAEKRYOUNGDO BEACH'}, {'stri
ng': u'KOREAN AIR FORCE HQ'}, {'string': u'PYONGTAEK'}, {'string': u'SUSAEK'}, {
'string': u'SEOUL EAST'}, {'string': u'KUNI'}, {'string': u'OSAN'}, {'string': u
'PAEKRYOUNGDO SITE'}, {'string': u'YEONGDONGRI'}, {'string': u'SEOUL'}, {'string
': u'TONGDUCHEON'}, {'string': u'YEOJU'}, {'string': u'SUWON'}, {'string': u'SON
G SAN-RI'}, {'string': u'SEOUL'}, {'string': u'ANDONG'}, {'string': u'CHUNGJU'},
 {'string': u'TAEJON'}, {'string': u'POHANG'}, {'string': u'KYUNGJU'}, {'string'
: u'TAEGU'}, {'string': u'SANGJU'}, {'string': u'CHONGJU'}, {'string': u'YECHON'
}, {'string': u'HAMHUNG'}, {'string': u'KIMCHAEK'}, {'string': u'PYONGYANG'}, {'
string': u'UAMA'}, {'string': u'UIJU'}]}

Original comment by marun...@gmail.com on 21 Feb 2013 at 9:08

GoogleCodeExporter commented 9 years ago
First, self.namespace in SoapClient instance set to correct value at 460 line 
in client.py 
=============================================================
        # Extract useful data:
        self.namespace = wsdl['targetNamespace']
=============================================================

But, self.namespace set to incorrect value at 591 line.
=============================================================
        # check axis2 namespace at schema types attributes
        self.namespace = dict(wsdl.types("schema", ns=xsd_uri)[:]).get('targetNamespace', self.namespace) 
=============================================================

Original comment by marun...@gmail.com on 28 Feb 2013 at 6:53

GoogleCodeExporter commented 9 years ago
sorry, I don't fully understand this, do you have a patch or fix?

Original comment by reingart@gmail.com on 28 Feb 2013 at 9:21

GoogleCodeExporter commented 9 years ago
I don't have a patch or fix.
I am a beginner for web service(soap,wsdl) and pysimplesoap.
I only test and compare it with other libraries and tools.

Original comment by marun...@gmail.com on 4 Mar 2013 at 4:09

GoogleCodeExporter commented 9 years ago
This appears to be working now in trunk with the latest changes (version 1.11, 
revision a16a09aa50ea):

https://code.google.com/p/pysimplesoap/source/detail?r=a16a09aa50ea01544ed7e5439
dfb63bed65bf8a8

The remote call returns:

ret = {'GetCitiesByCountryResult': [{'string': u'KWANGJU'}, {'string': 
u'KUNSAN'}, {'string': u'MOKPO'}, {'string': u'JHUNJU'}, {'string': u'YEOSU'}, 
{'string': u'CHUNCHON'}, {'string': u"SOKCH'O"}, {'string': u'HEONGSUNG'}, 
{'string': u'INJAE'}, {'string': u'KWANDAERI'}, {'string': u'KANGNUNG'}, 
{'string': u'SAMCHOK'}, {'string': u'WONJU'}, {'string': u'YANGKU'}, {'string': 
u'CHEJU'}, {'string': u'CHINHAE'}, {'string': u'KIMHAE'}, {'string': u'CHEJU'}, 
{'string': u'BUSAN'}, {'string': u'SACHON'}, {'string': u'ULSAN'}, {'string': 
u'ASCOM CITY'}, {'string': u'UIJEONGBU'}, {'string': u'CHEONGOKRI'}, {'string': 
u'PAEKRYOUNGDO BEACH'}, {'string': u'KOREAN AIR FORCE HQ'}, {'string': 
u'PYONGTAEK'}, {'string': u'SUSAEK'}, {'string': u'SEOUL EAST'}, {'string': 
u'KUNI'}, {'string': u'OSAN'}, {'string': u'PAEKRYOUNGDO SITE'}, {'string': 
u'YEONGDONGRI'}, {'string': u'SEOUL'}, {'string': u'TONGDUCHEON'}, {'string': 
u'YEOJU'}, {'string': u'SUWON'}, {'string': u'SONG SAN-RI'}, {'string': 
u'SEOUL'}, {'string': u'ANDONG'}, {'string': u'CHUNGJU'}, {'string': 
u'TAEJON'}, {'string': u'POHANG'}, {'string': u'KYUNGJU'}, {'string': 
u'TAEGU'}, {'string': u'SANGJU'}, {'string': u'CHONGJU'}, {'string': 
u'YECHON'}, {'string': u'HAMHUNG'}, {'string': u'KIMCHAEK'}, {'string': 
u'PYONGYANG'}, {'string': u'UAMA'}, {'string': u'UIJU'}]}

(test pending)

Original comment by reingart@gmail.com on 29 Aug 2013 at 8:45

GoogleCodeExporter commented 9 years ago
The error is fixed in the latest developement version 1.12

Please download and test the latest source code from the repository until the 
release:

https://pysimplesoap.googlecode.com/archive/default.zip

Added a test in revision bd14457ab3eb

Original comment by reingart@gmail.com on 22 Jan 2014 at 4:38

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
This bug is a pretty much a show stopper for interop between .NET WCF services. 

Even if you utilize the new .NET 4.5 "singleWsdl" feature, you will still 
encounter this issue with xml imports when using complex type paramters, if the 
namespace defined in the attribute [ServiceContract(NameSpace="www.Service")] 
isn't the same as the namespace in [DataContract(Namespace="www.Contract")].

Is this fix being planned be released in a new stable version any time soon?

Original comment by d.li...@gmail.com on 3 Sep 2014 at 6:57

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for reporting and providing the wsdl, I'm planning to make a new release 
soon (maybe later this month), after fixing some important open issues.

In the meantime, you can download 1.12 from 
https://pysimplesoap.googlecode.com/archive/1.12.zip (or even 1.13) and try it, 
let me know if that solves your problem to see if this bug is a regression.

Original comment by reingart@gmail.com on 3 Sep 2014 at 7:04

GoogleCodeExporter commented 9 years ago
I have already verified that 1.12 fixes these issues.  Thanks for the quick 
update!  We will be eagerly waiting for the new release :D

Original comment by d.li...@gmail.com on 3 Sep 2014 at 7:29