使用Suds的端口类型异常 [英] Exception in port type using Suds

查看:176
本文介绍了使用Suds的端口类型异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码使用Python Suds连接到Aramex发行的SOAP API:

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

可以在此处找到WSDL文件源.

The WSDL file source can be found here.

推荐答案

错误在这里:

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

还有

binding元素具有两个属性-name和type.

The binding element has two attributes - name and type.

name属性(您可以使用任意名称)定义了 绑定,并且type属性指向该端口 绑定,在这种情况下为"glossaryTerms"端口.

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.

因此解析器找不到端口type="i0:Service_1_0",在此wsdl文件中有两个端口定义:

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>

因此,现在您知道出了什么问题(wsdl:binding中的更改类型),并且您无法通过该验证.

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

这篇关于使用Suds的端口类型异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆