Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django soaplib&;泡沫几乎起作用[错误泡沫]_Django_Soap_Suds - Fatal编程技术网

Django soaplib&;泡沫几乎起作用[错误泡沫]

Django soaplib&;泡沫几乎起作用[错误泡沫],django,soap,suds,Django,Soap,Suds,一方面,Django公开了一个SOAP入口点: soaplib 1.0 soaplib_handler.py # http://djangosnippets.org/snippets/2210/ from django.http import HttpResponse import StringIO from soaplib.serializers.primitive import Boolean, String from soaplib.service import DefinitionBa

一方面,Django公开了一个SOAP入口点:

soaplib 1.0

soaplib_handler.py

# http://djangosnippets.org/snippets/2210/

from django.http import HttpResponse
import StringIO
from soaplib.serializers.primitive import Boolean, String
from soaplib.service import DefinitionBase, rpc
from soaplib.wsgi import Application

# the class with actual web methods
class MySOAPService(DefinitionBase):
    @rpc(String, String, _returns=String)
    def foo(self, t1, t2):
        return "OK"

# the class which acts as a wrapper between soaplib WSGI functionality and Django
class DjangoSoapApp(Application):
    def __call__(self, request):
        # wrap the soaplib response into a Django response object
        django_response = HttpResponse()
        def start_response(status, headers):
            status, reason = status.split(' ', 1)
            django_response.status_code = int(status)
            for header, value in headers:
                django_response[header] = value
        response = super(DjangoSoapApp, self).__call__(request.META, start_response)
        django_response.content = '\n'.join(response)
        return django_response
core.views.py

from soaplib_handler import DjangoSoapApp, MySOAPService

my_soap_service = DjangoSoapApp([MySOAPService], 'Mydeal')
url.py

 url(r'^hello_world/', 'core.views.my_soap_service'),

 url(r'^hello_world/service.wsdl', 'core.views.my_soap_service'),
当我收到:

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:plink="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:senc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s0="Mydeal" xmlns:s12env="http://www.w3.org/2003/05/soap-envelope/" xmlns:s12enc="http://www.w3.org/2003/05/soap-encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="Mydeal" name="DjangoSoapApp">
 <wsdl:types>
  <xs:schema targetNamespace="Mydeal" elementFormDefault="qualified">
   <xs:element name="foo" type="s0:foo" />
   <xs:element name="fooResponse" type="s0:fooResponse" />
   <xs:complexType name="foo">
    <xs:sequence>
     <xs:element name="t1" type="xs:string" minOccurs="0" nillable="true" />
     <xs:element name="t2" type="xs:string" minOccurs="0" nillable="true" />
     </xs:sequence>
    </xs:complexType>
   <xs:complexType name="fooResponse">
    <xs:sequence>
     <xs:element name="fooResult" type="xs:string" minOccurs="0" nillable="true" />
     </xs:sequence>
    </xs:complexType>
   </xs:schema>
  </wsdl:types>
 <wsdl:message name="foo">
  <wsdl:part name="foo" element="s0:foo" />
  </wsdl:message>
 <wsdl:message name="fooResponse">
  <wsdl:part name="fooResponse" element="s0:fooResponse" />
  </wsdl:message>
 <wsdl:service name="DjangoSoapApp">
  <wsdl:port name="DjangoSoapApp" binding="s0:DjangoSoapApp">
   <soap:address location="http://localhost:8001/hello_world/service" />
   </wsdl:port>
  </wsdl:service>
 <wsdl:portType name="DjangoSoapApp">
  <wsdl:operation name="foo" parameterOrder="foo">
   <wsdl:input name="foo" message="s0:foo" />
   <wsdl:output name="fooResponse" message="s0:fooResponse" />
   </wsdl:operation>
  </wsdl:portType>
 <wsdl:binding name="DjangoSoapApp" type="s0:DjangoSoapApp">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="foo">
   <soap:operation soapAction="foo" style="document" />
   <wsdl:input name="foo">
    <soap:body use="literal" />
    </wsdl:input>
   <wsdl:output name="fooResponse">
    <soap:body use="literal" />
    </wsdl:output>
   </wsdl:operation>
  </wsdl:binding>
 </wsdl:definitions>
给出以下错误:

======================================================================
ERROR: test_callback (__main__.TestM2TScenarioI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 370, in test_callback
    client_endpoint = Client(WSDL)
  File "/home/gregory/.virtualenvs/casadeal/lib/python2.6/site-packages/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
  File "/home/gregory/.virtualenvs/casadeal/lib/python2.6/site-packages/suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
  File "/home/gregory/.virtualenvs/casadeal/lib/python2.6/site-packages/suds/wsdl.py", line 158, in __init__
    self.resolve()
  File "/home/gregory/.virtualenvs/casadeal/lib/python2.6/site-packages/suds/wsdl.py", line 207, in resolve
    c.resolve(self)
  File "/home/gregory/.virtualenvs/casadeal/lib/python2.6/site-packages/suds/wsdl.py", line 495, in resolve
    raise Exception("msg '%s', not-found" % op.input)
Exception: msg 's0:Test', not-found

----------------------------------------------------------------------
Ran 1 test in 0.053s

我在soaplib 2.0测试版上也遇到了同样的问题。我得换衣服

my_soap_service = DjangoSoapApp([MySOAPService], 'Mydeal')

这起作用了

my_soap_service = DjangoSoapApp([MySOAPService], 'Mydeal')
my_soap_service = DjangoSoapApp([MySOAPService], 'Mydeal', name='Mydeal')