2017-09-11 8 views
0

私はSOAP要求を行うためにZEEPを使用しようとしています。WSDL内のwsdl:サービス定義が見つかりません

私はこの要求だ:

def status(request, IP): 
    URL = "http://" + IP + "/Service" 
    session = Session() 
    session.auth = HTTPBasicAuth('username', 'password') 
    client = Client(URL, 
        transport=Transport(session=session), strict=False) 

    response = client.service.Method1(request={'getList'}) 

    return response 

をしかし、私はエラーが不足しているのwsdl打ってる:WSDLでのサービス定義を。

私は立ち往生しています。フォールトサーチにこれ以上の方法が見つかりません。何か考えましたか?

コンテキストを編集します。これが動作し、私はZEEPでやろうとしているハードコードさリクエストです:

def GetList(session, IP):   

     request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' 
     request = request + '<soapenv:Header>' 
     request = request + '<session>' + session + '</session>' 
     request = request + ' </soapenv:Header>' 
     request = request + ' <soapenv:Body>' 
     request = request + '<getList/>' 
     request = request + '</soapenv:Body>' 
     request = request + '</soapenv:Envelope>' 

     request = u"""""" + request + """""".format() 

     encoded_request = request.encode('utf-8') 

     headers = {"Host": ""+ IP +"", 
        "Content-Type": "text/xml; charset=UTF-8", 
        "Content-Length": str(len(encoded_request)), 
        "SOAPAction": ""} 

     response = requests.post(url="http://"+ url +"/Service", 
           headers=headers, 
           data=encoded_request, 
           verify=False) 

     return response.content 

編集2.あなたは、あなたのURL変数の末尾に?wsdlを追加する必要があり、WSDL

<?xml version="1.0" encoding="UTF-8"?>  
-<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:intf="http://xml.apache.org/axis/wsdd/ " xmlns:impl="http://xml.apache.org/axis/wsdd/ " xmlns:apachesoap="http://xml.apache.org/xml-soap" targetNamespace="http://xml.apache.org/axis/wsdd/ ">  
-<wsdl:types>  
-<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.apache.org/axis/wsdd/ ">  
<element type="xsd:anyType" name="parseMessage"/>  
<element type="xsd:anyType" name="parseMessageReturn"/>  
</schema>  
</wsdl:types>  
-<message name="parseMessageResponse">  
<part name="parseMessageReturn" element="impl:parseMessageReturn"/>  
</message>  
-<message name="parseMessageRequest">  
<part name="part" element="impl:parseMessage"/>  
</message>  
-<portType name="MessageHandlerProxy">  
-<operation name="parseMessage">  
<input name="parseMessageRequest" message="impl:parseMessageRequest"/>  
<output name="parseMessageResponse" message="impl:parseMessageResponse"/>  
</operation>  
</portType>  
-<binding type="impl:HandlerProxy" name="ServiceBinding">  
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>  
-<operation name="parseMessage">  
<wsdlsoap:operation soapAction=""/>  
-<input name="parseMessageRequest">  
<wsdlsoap:body use="literal" namespace="http://xml.apache.org/axis/wsdd/ "/>  
</input>  
-<output name="parseMessageResponse">  
<wsdlsoap:body use="literal" namespace="http://xml.apache.org/axis/wsdd/ "/>  
</output>  
</operation>  
</binding>  
-<service name="ProxyService">  
-<port name="Service" binding="impl:ServiceBinding">  
<wsdlsoap:address location="http://ip.ip.ip.ip/Service"/>  
</port>  
</service>  
</definitions> 
+0

正しいURLを渡していることを確認できますか?このURLをSOAPクライアントで試してうまくいったのですか?それは '' http:// some_IP_here/Service?wsdl''の形式でなければなりません。 – Galil

+0

@Galil私はエクスプローラを開くことができますが、Chromeは開けません。 Chromeはエラーをスローする:207行目の2行目の_error:xmlns:impl: 'http://xml.apache.org/axis/wsdd/'は有効なURIではない 次に実行する: 'python -mzeep URL? wsdl' chromeと同じエラーが発生します:_zeep.exceptions.XMLSyntaxError:無効なXMLコンテンツが受信されました(xmlns:impl: 'http://xml.apache.org/axis/wsdd/'は有効なURI 2行目ではありません207)_ 'python -mzeep --no-strict URL?wsdl'を実行してもエラーは発生しません – sumpen

+0

URL変数に' '?wsdl''を追加しましたか?次のようになります。 "URL =" http:// "+ IP +"/Service?wsdl "' '。あなたの機能をもう一度テストしましたか? – Galil

答えて

0

を追加します。 。

また、通話方法が正しくありません。 getListへの電話は、次のようになります。

def status(request, IP): 
    URL = "http://" + IP + "/Service?wsdl" 
    session = Session() 
    session.auth = HTTPBasicAuth('username', 'password') 
    client = Client(URL, 
        transport=Transport(session=session), strict=False) 

    response = client.service.getList([add the arguments here]) 

    return response 
+0

これは私にエラーを返します:AttributeError _Serviceには操作がありません' getList'_ これもこう言います:_上記例外の処理中{http://xml.apache.org/axis/wsdd/} MessageServiceBindingにそのような操作 'getList'はありませんでしたが、別の例外が発生しました:_ それは_http://xml.apacheではないので不思議です。 org/axis/wsdd/_ – sumpen

+0

このエラーは、このような呼び出しがないことを意味します。 '' getList''というコールがありますか?それは正しく綴られていますか?私は例として '' getList''呼び出しを使いました。使用するAPI呼び出しの名前に置き換える必要があります。 – Galil

+0

はい、私は正解です。私はいくつかの文脈で質問を更新しました。これは動作しているハードコードされた要求の例です。そして、あなたはが呼び出されているのを見ることができます。だから私はハードコードされたコードでリクエストを行うことができます。しかし、ジープではありません。そして私は何が間違っているのか分かりません。私は本当にあなたが提供しているすべてのあなたの助けに感謝します。 – sumpen

関連する問題