Exception in port type using Suds

泄露秘密 提交于 2020-01-04 19:16:45

问题


I am trying to connect to Aramex shipping SOAP API using Python Suds using following code:

import suds
from suds.client import Client
client = Client('file:///home/test/test_wsdl_aramex/shipments-tracking-api-wsdl.wsdl',cache=None)

But after starting, I get the following exception:

>     raise Exception("portType '%s', not-found" % self.type)
Exception: portType 'i0:Service_dd1_0', not-found

The WSDL file source can be found here.


回答1:


Error is here:

<wsdl:binding type="i0:Service_1_0" name="BasicHttpBinding_Service_1_0">

And

The binding element has two attributes - name and type.

The name attribute (you can use any name you want) defines the name of the binding, and the type attribute points to the port for the binding, in this case the "glossaryTerms" port.

So parser can't find port type="i0:Service_1_0", in this wsdl file there are two ports definition:

<wsdl:portType name="Service_1_0">
    <wsdl:operation name="TrackShipments">
      <wsdl:input name="ShipmentTrackingRequest" message="tns:ShipmentTrackingRequest" wsaw:Action="http://ws.aramex.net/ShippingAPI/v1/Service_1_0/TrackShipments"/>
      <wsdl:output name="ShipmentTrackingResponse" message="tns:ShipmentTrackingResponse" wsaw:Action="http://ws.aramex.net/ShippingAPI/v1/Service_1_0/TrackShipmentsResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:service name="Service_1_0">
    <wsdl:port name="BasicHttpBinding_Service_1_0" binding="i0:BasicHttpBinding_Service_1_0">
      <soap:address location="http://ws.aramex.net/shippingapi/tracking/service_1_0.svc"/>
    </wsdl:port>
  </wsdl:service>

So now you know what is wrong(change type in wsdl:binding), and you can't pass the validation of that.



来源:https://stackoverflow.com/questions/17999476/exception-in-port-type-using-suds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!