使用sud的pythonsoap有问题

使用sud的pythonsoap有问题,python,soap,suds,Python,Soap,Suds,我的肥皂水有问题,我不知道是什么让它变成这样。 我试图调用一个Web服务,该服务将一个复杂类型作为 参数(ShippingGuideRequestType)。我将发布我的pdb会话,并尝试解释 正在发生。您看到的'request'变量的类型为ShippingGuideRequestType和 它是使用client.factory.create(“ShippingGuideRequestType”)创建的 现在让我们来处理使用 client.factory.create(“ProductIdsTy

我的肥皂水有问题,我不知道是什么让它变成这样。 我试图调用一个Web服务,该服务将一个复杂类型作为 参数(ShippingGuideRequestType)。我将发布我的pdb会话,并尝试解释 正在发生。您看到的'request'变量的类型为ShippingGuideRequestType和 它是使用client.factory.create(“ShippingGuideRequestType”)创建的

现在让我们来处理使用 client.factory.create(“ProductIdsType”):

最后一个必需的属性是PackageInputType,它是在一个位中创建的 更复杂的方式。首先创建PackageInputType,然后创建一个数组 PackageInputType(使用client.factory.create(“PackageInputType”))

(Pdb)包输入
(PackageInputType){
套餐[]=
(PackageInputType){
高度=
(单位代码长度类型){
值=10
_unitCode=“CMT”
}
宽度=
(单位代码长度类型){
值=10
_unitCode=“CMT”
}
长度=
(单位代码长度类型){
值=10
_unitCode=“CMT”
}
格罗斯怀特=
(单位代码权重类型){
值=1000
_unitCode=“GRM”
}
体积=
(UnitCodeCubicType){
值=无
_unitCode=“DMQ”
}
体积特别=无
FromCountryCode=无
FromPostalCode=“7800”
ToCountryCode=无
ToPostalCode=“7041”
发货日期=
(日期和时间类型){
年份=无
月份=无
天=无
小时=无
分钟=无
}
附加服务=
(附加服务Puttype){
附加服务[]=
}
EarlyCollectionAtTerminal=无
_packageId=“myRef”
},
}
(Pdb)request.UserInformation=用户信息
(Pdb)request.productId=productsInput
(Pdb)request.Packages=packagesInput
(Pdb)请求
(ShippingGuideRequestType){
用户信息=
(用户信息类型){
Usercode=“-CENCORED”
}
请求属性=
(RequestPropertiesType){
图式厌恶=无
语言=无
WithPrice=无
WithExpectedDelivery=无
WithGuiInformation=None
NumberOfAlternativeDeliveryDates=无
EDI=无
PostingAtPostoffice=无
跟踪=无
}
ProductId=
(ProductIdsType){
ProductId[]=
“SERVICEPAKKE”,
}
寄售=
(委托输入类型){
FromCountryCode=无
FromPostalCode=无
ToCountryCode=无
拓扑代码=无
发货日期=
(日期和时间类型){
年份=无
月份=无
天=无
小时=无
分钟=无
}
EarlyCollectionAtTerminal=无
附加服务=
(附加服务Puttype){
附加服务[]=
}
}
包裹=
(PackageInputType){
套餐[]=
(PackageInputType){
高度=
(单位代码长度类型){
值=10
_unitCode=“CMT”
}
宽度=
(单位代码长度类型){
值=10
_unitCode=“CMT”
}
长度=
(单位代码长度类型){
值=10
_unitCode=“CMT”
}
格罗斯怀特=
(单位代码权重类型){
值=1000
_unitCode=“GRM”
}
体积=
(UnitCodeCubicType){
值=无
_unitCode=“DMQ”
}
体积特别=无
FromCountryCode=无
FromPostalCode=“7800”
ToCountryCode=无
ToPostalCode=“7041”
发货日期=
(日期和时间类型){
年份=无
月份=无
天=无
小时=无
分钟=无
}
附加服务=
(附加服务Puttype){
附加服务[]=
}
EarlyCollectionAtTerminal=无
_packageId=“myRef”
},
}
}
在我看来,结构看起来不错,现在让我们尝试调用服务

(Pdb) self.client.service.ShippingGuide(request) 
2011-02-28 14:32:37 ERROR suds.client <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://www.bring.no/logistics/shippingguide/1.0" 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:ShippingGuideRequest>
         <ns0:UserInformation>
            <ns0:UserInformation>
               <ns0:Usercode>-CENCORED-</ns0:Usercode>
            </ns0:UserInformation>
            <ns0:RequestProperties>
               <ns0:SchemaVersion/>
            </ns0:RequestProperties>
            <ns0:ProductIds>
               <ns0:ProductId>SERVICEPAKKE</ns0:ProductId>
            </ns0:ProductIds>
            <ns0:Packages>
               <ns0:Package packageId="myRef">
                  <ns0:Height unitCode="CMT">10</ns0:Height>
                  <ns0:Width unitCode="CMT">10</ns0:Width>
                  <ns0:Length unitCode="CMT">10</ns0:Length>
                  <ns0:GrossWeight unitCode="GRM">1000</ns0:GrossWeight>
                  <ns0:Volume unitCode="DMQ"/>
                  <ns0:FromCountryCode/>
                  <ns0:FromPostalCode>7800</ns0:FromPostalCode>
                  <ns0:ToCountryCode/>
                  <ns0:ToPostalCode>7041</ns0:ToPostalCode>
               </ns0:Package>
            </ns0:Packages>
         </ns0:UserInformation>
         <ns0:RequestProperties/>
         <ns0:ProductIds/>
         <ns0:Packages/>
      </ns0:ShippingGuideRequest>
   </ns1:Body>
</SOAP-ENV:Envelope>
*** WebFault: Server raised fault: 'FG_INPUT_003 User information missing from request. [errorId cf19f72b-0795-4f58-8a70-a8c1846ba186]'
(Pdb)self.client.service.ShippingGuide(请求)
2011-02-28 14:32:37错误suds.client
-森科雷德-
SERVICEPAKKE
10
10
10
1000
7800
7041
***WebFault:服务器引发的错误:“请求中缺少FG\U INPUT\U 003用户信息。[错误ID cf19f72b-0795-4f58-8a70-a8c1846ba186]'

这里发生了什么事?为什么所有内容都编码在UserInformation元素中?

您尝试过了吗:

shipping = client.factory.create("ShippingGuideRequestType")

shipping.UserInformation.UserCode = val1

shipping.RequestProperties.SchemaVersion = val2
shipping.RequestProperties.Language = val3

//Add the rest of the values.

client.service.shippingFunction(shipping)
(Pdb) productsInput
(ProductIdsType){
   ProductId[] = 
      "SERVICEPAKKE",
 }
(Pdb) packagesInput
(PackagesInputType){
   Package[] = 
      (PackageInputType){
         Height = 
            (UnitCodeLengthType){
               value = 10
               _unitCode = "CMT"
            }
         Width = 
            (UnitCodeLengthType){
               value = 10
               _unitCode = "CMT"
            }
         Length = 
            (UnitCodeLengthType){
               value = 10
               _unitCode = "CMT"
            }
         GrossWeight = 
            (UnitCodeWeightType){
               value = 1000
               _unitCode = "GRM"
            }
         Volume = 
            (UnitCodeCubicType){
               value = None
               _unitCode = "DMQ"
            }
         VolumeSpecial = None
         FromCountryCode = None
         FromPostalCode = "7800"
         ToCountryCode = None
         ToPostalCode = "7041"
         ShippingDate = 
            (DateAndTimeType){
               Year = None
               Month = None
               Day = None
               Hour = None
               Minute = None
            }
         AdditionalServices = 
            (AdditionalServicesInputType){
               AdditionalService[] = <empty>
            }
         EarlyCollectionAtTerminal = None
         _packageId = "myRef"
      },
 }
(Pdb) request.UserInformation = userInformation
(Pdb) request.ProductIds = productsInput
(Pdb) request.Packages = packagesInput
(Pdb) request
(ShippingGuideRequestType){
   UserInformation = 
      (UserInformationType){
         Usercode = "-CENCORED"
      }
   RequestProperties = 
      (RequestPropertiesType){
         SchemaVersion = None
         Language = None
         WithPrice = None
         WithExpectedDelivery = None
         WithGuiInformation = None
         NumberOfAlternativeDeliveryDates = None
         EDI = None
         PostingAtPostoffice = None
         Trace = None
      }
   ProductIds = 
      (ProductIdsType){
         ProductId[] = 
            "SERVICEPAKKE",
      }
   Consignment = 
      (ConsignmentInputType){
         FromCountryCode = None
         FromPostalCode = None
         ToCountryCode = None
         ToPostalCode = None
         ShippingDate = 
            (DateAndTimeType){
               Year = None
               Month = None
               Day = None
               Hour = None
               Minute = None
            }
         EarlyCollectionAtTerminal = None
         AdditionalServices = 
            (AdditionalServicesInputType){
               AdditionalService[] = <empty>
            }
      }
   Packages = 
      (PackagesInputType){
         Package[] = 
            (PackageInputType){
               Height = 
                  (UnitCodeLengthType){
                     value = 10
                     _unitCode = "CMT"
                  }
               Width = 
                  (UnitCodeLengthType){
                     value = 10
                     _unitCode = "CMT"
                  }
               Length = 
                  (UnitCodeLengthType){
                     value = 10
                     _unitCode = "CMT"
                  }
               GrossWeight = 
                  (UnitCodeWeightType){
                     value = 1000
                     _unitCode = "GRM"
                  }
               Volume = 
                  (UnitCodeCubicType){
                     value = None
                     _unitCode = "DMQ"
                  }
               VolumeSpecial = None
               FromCountryCode = None
               FromPostalCode = "7800"
               ToCountryCode = None
               ToPostalCode = "7041"
               ShippingDate = 
                  (DateAndTimeType){
                     Year = None
                     Month = None
                     Day = None
                     Hour = None
                     Minute = None
                  }
               AdditionalServices = 
                  (AdditionalServicesInputType){
                     AdditionalService[] = <empty>
                  }
               EarlyCollectionAtTerminal = None
               _packageId = "myRef"
            },
      }
 }
(Pdb) self.client.service.ShippingGuide(request) 
2011-02-28 14:32:37 ERROR suds.client <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://www.bring.no/logistics/shippingguide/1.0" 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:ShippingGuideRequest>
         <ns0:UserInformation>
            <ns0:UserInformation>
               <ns0:Usercode>-CENCORED-</ns0:Usercode>
            </ns0:UserInformation>
            <ns0:RequestProperties>
               <ns0:SchemaVersion/>
            </ns0:RequestProperties>
            <ns0:ProductIds>
               <ns0:ProductId>SERVICEPAKKE</ns0:ProductId>
            </ns0:ProductIds>
            <ns0:Packages>
               <ns0:Package packageId="myRef">
                  <ns0:Height unitCode="CMT">10</ns0:Height>
                  <ns0:Width unitCode="CMT">10</ns0:Width>
                  <ns0:Length unitCode="CMT">10</ns0:Length>
                  <ns0:GrossWeight unitCode="GRM">1000</ns0:GrossWeight>
                  <ns0:Volume unitCode="DMQ"/>
                  <ns0:FromCountryCode/>
                  <ns0:FromPostalCode>7800</ns0:FromPostalCode>
                  <ns0:ToCountryCode/>
                  <ns0:ToPostalCode>7041</ns0:ToPostalCode>
               </ns0:Package>
            </ns0:Packages>
         </ns0:UserInformation>
         <ns0:RequestProperties/>
         <ns0:ProductIds/>
         <ns0:Packages/>
      </ns0:ShippingGuideRequest>
   </ns1:Body>
</SOAP-ENV:Envelope>
*** WebFault: Server raised fault: 'FG_INPUT_003 User information missing from request. [errorId cf19f72b-0795-4f58-8a70-a8c1846ba186]'
shipping = client.factory.create("ShippingGuideRequestType")

shipping.UserInformation.UserCode = val1

shipping.RequestProperties.SchemaVersion = val2
shipping.RequestProperties.Language = val3

//Add the rest of the values.

client.service.shippingFunction(shipping)