php - 使用SOAP XML Request与交付公司集成

时间:2016-11-11 16:47:05

标签: php xml api soap

SOAP API集成的新手,但确实有PHP语言经验。

测试集成的链接位于:http://168.187.136.18:8090/APIService/PostaWebClient.svc

送货公司只发送了关于C语言的文档,您可以在此处查看:https://www.pdf-archive.com/2016/11/11/documentation-for-customer-portal-api-v7-2-1-1/

还有参考数据:

CODEALPHA3   CODEALPHA2   NAME
USA            US         United States

我不知道如何使用PHP将此作为请求发送,以及如何获得响应。

非常感谢任何帮助。

SOAP格式:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"
xmlns:pos="http://schemas.datacontract.org/2004/07/PostaWebClient">
 <soapenv:Header/>
 <soapenv:Body>
 <tem:Shipment_Creation>
 <!— Optional:-->
 <tem:SHIPINFO>
 <pos:AppointmentDate> If Customer has given exact date for delivery </pos:AppointmentDate>
 <!--Optional:-->
 <pos:AppointmentFromTime> From Time </pos:AppointmentFromTime>
 <!--Optional:-->
 <pos:AppointmentToTime> To Time </pos:AppointmentToTime>
 <!--Optional:-->
 <pos:CashOnDelivery> Amount of Cash on Delivery </pos:CashOnDelivery>
 <!--Optional:-->
 <pos:CashOnDeliveryCurrency> Currency of cash on delivery </pos:CashOnDeliveryCurrency>
 <!--Optional:-->
 <pos:ClientInfo>
 <!-- Required Field:-->
 <pos:CodeStation> Posta Account Station Code </pos:CodeStation>
 <!-- Required Field:-->
 <pos:Password> Shipper Account Password </pos:Password>
 <!-- Required Field:-->
 <pos:ShipperAccount> Shipper Account No. </pos:ShipperAccount>
 <!-- Required Field:-->
 <pos:UserName> Shipper Account Username </pos:UserName>
 </pos:ClientInfo>
 <!--Optional:-->
 <pos:CodeCurrency> Currency Code </pos:CodeCurrency>
 <!-- Required Field:-->
 <pos:CodeService> Service Code(Refer to Reference Data 4.3) </pos:CodeService>
 <!-- Required Field:-->
 <pos:CodeShippmentType> Shipment Type Code(Refer to Reference Data 4.4) </pos:CodeShippmentType>
 <!--Optional:-->
 <pos:ConnoteContact>
 <!--Optional:-->
 <pos:Email1> Email id 1 </pos:Email1>
 <!--Optional:-->
 <pos:Email2> Email id 2 </pos:Email2>
 <!--Optional:-->
 <pos:TelHome> Tel/ Mobile No. (Including Country Code) </pos:TelHome>
 <!-- Required Field:-->
 <pos:TelMobile> Tel/ Mobile No. (Including Country Code) </pos:TelMobile>
 <!--Optional:-->
 <pos:WhatsAppNumber> Tel/ Mobile No. (Including Country Code) </pos:WhatsAppNumber>
 </pos:ConnoteContact>
 <!-- Required Field:-->
 <pos:ConnoteDescription> Shipment Description </pos:ConnoteDescription>
 <!--Optional:-->
 <pos:ConnoteInsured> Y / N </pos:ConnoteInsured>
 <!--Optional:-->
 <pos:ConnoteNotes>
 <!--Optional:-->
 <pos:Note1> Note 1 </pos:Note1>
 <!--Optional:-->
 <pos:Note2> Note 2 </pos:Note2>
 <!--Optional:-->
 <pos:Note3> Note 3 </pos:Note3> 
 <!--Optional:-->
 <pos:Note4> Note 4 </pos:Note4>
 <!--Optional:-->
 <pos:Note5> Note 5 </pos:Note5>
 <!--Optional:-->
 <pos:Note6> Note 6 </pos:Note6>
 </pos:ConnoteNotes>
 <!--Optional:-->
 <pos:ConnotePerformaInvoice>
 <!--Zero or more repetitions:-->
 <pos:CONNOTEPERMINV>
 <!--Optional:-->
 <pos:CodeHS> It is Compulsory, if shipment type is INTL NON DOC (Refer to Reference Data 4.5) </pos:CodeHS>
 <!--Optional:-->
 <pos:CodePackageType> Type of Package (Refer to Reference Data 4.6) </pos:CodePackageType>
 <!--Optional:-->
 <pos:Description> Item Description </pos:Description>
 <!--Optional:-->
 <pos:OrginCountry> Origin Country (Refer to Reference Excel) </pos:OrginCountry>
 <!--Optional:-->
 <pos:Quantity> Required Quantity </pos:Quantity>
 <!--Optional:-->
 <pos:RateUnit> Unit Rate Amount </pos:RateUnit>
 </pos:CONNOTEPERMINV>
 </pos:ConnotePerformaInvoice>
 <!-- Required Field:-->
 <pos:ConnotePieces> No. of Pieces </pos:ConnotePieces>
 <!--Optional:-->
 <pos:ConnoteProhibited> Y/ N </pos:ConnoteProhibited>
 <!--Optional:-->
 <pos:ConnoteRef>
 <!--Optional:-->
 <pos:Reference1> Shipper Reference </pos:Reference1>
 <!--Optional:-->
 <pos:Reference2> Consignee Reference </pos:Reference2>
 </pos:ConnoteRef>
 <!--Optional:-->
 <pos:Consignee>
 <!--Optional:-->
 <pos:Company> Consignee Company </pos:Company>
 <!-- Required Field:-->
 <pos:FromAddress> Shipper Address </pos:FromAddress>
 <!-- Required Field:-->
 <pos:FromArea> Shipper POSTA Country Area Code(Refer to Reference Excel) </pos:FromArea>
 <!-- Required Field:-->
 <pos:FromCity> Shipper POSTA Country City Code </pos:FromCity>
 <!-- Required Field:-->
 <pos:FromCodeCountry> Shipper POSTA Country Code </pos:FromCodeCountry>
 <!-- Required Field:-->
 <pos:FromMobile> Shipper Tel/Mobile No (Including Country Code)</pos:FromMobile>
 <!-- Required Field:-->
 <pos:FromName> Shipper Name </pos:FromName>
 <!--Optional:-->
 <pos:FromPinCode> Shipper Area Pincode </pos:FromPinCode>
 <!-- Required Field:-->
 <pos:FromProvince> Shipper POSTA Country Province Code </pos:FromProvince>
 <!-- Required Field:-->
 <pos:FromTelphone> Shipper Tel/Mobile No. (Including Country Code) </pos:FromTelphone> 
 <!--Optional:-->
 <pos:Remarks> Remarks </pos:Remarks>
 <!-- Required Field:-->
 <pos:ToAddress> Consignee Address </pos:ToAddress>
 <!-- Required Field:-->
 <pos:ToArea> Consignee POSTA Country Area Code </pos:ToArea>
 <!-- Required Field:-->
 <pos:ToCity> Consignee POSTA Country City Code </pos:ToCity>
 <!--Optional:-->
 <pos:ToCivilID> Consignee Civil ID </pos:ToCivilID>
 <!-- Required Field:-->
 <pos:ToCodeCountry> Consignee POSTA Country Code </pos:ToCodeCountry>
 <!--Optional:-->
 <pos:ToCodeSector> POSTA Sector Code </pos:ToCodeSector>
 <!--Optional:-->
 <pos:ToDesignation> Consignee Designation </pos:ToDesignation>
 <!-- Required Field:-->
 <pos:ToMobile> Consignee Tel/Mobile No. (Including Country Code) </pos:ToMobile>
 <!-- Required Field:-->
 <pos:ToName> Consignee Name </pos:ToName>
 <!--Optional:-->
 <pos:ToPinCode> Consignee Area Pincode </pos:ToPinCode>
 <!-- Required Field:-->
 <pos:ToProvince> Consignee POSTA Country Province Code </pos:ToProvince>
 <!-- Required Field:-->
 <pos:ToTelPhone> Consignee Tel/Mobile No.( Including Country Code) </pos:ToTelPhone>
 </pos:Consignee>
 <!-- Required Field:-->
 <pos:CostShipment> Cost of the Shipment </pos:CostShipment>
 <!--Optional:-->
 <pos:ItemDetails>
 <!--Zero or more repetitions:-->
 <pos:ITEMDETAILS>
 <!-- Required Field:-->
 <pos:ConnoteHeight> Shipment Height </pos:ConnoteHeight>
 <!-- Required Field:-->
 <pos:ConnoteLength> Shipment Length </pos:ConnoteLength>
 <!-- Required Field:-->
 <pos:ConnoteWeight> Shipment Weight </pos:ConnoteWeight>
 <!-- Required Field:-->
 <pos:ConnoteWidth> Shipment Width </pos:ConnoteWidth>
 </pos:ITEMDETAILS>
 </pos:ItemDetails>
 <!--Optional:-->
 <pos:NeedRoundTrip> Y/N </pos:NeedRoundTrip>
 </tem:SHIPINFO>
 </tem:Shipment_Creation>
 </soapenv:Body>
</soapenv:Envelope> 

1 个答案:

答案 0 :(得分:0)

这是一个标准的SOAP 如果您有使用PHP的经验,请使用此http://php.net/manual/en/book.soap.php

有一些例子如何读写。

如果您需要特定问题的特殊帮助,请描述并告知我们。

你有 http://168.187.136.18:8090/APIService/PostaWebClient.svc?wsdl http://168.187.136.18:8090/APIService/PostaWebClient.svc?singleWsdl

看到你丢失了可用的功能:

"localhost"

所以你会知道要调用什么函数。 例如,使用此代码,它来自php docs

....
wsdl:message name="IPostaWebClient_Pickup_Creation_InputMessage">
<wsdl:part name="parameters" element="tns:Pickup_Creation"/>
</wsdl:message>
<wsdl:message name="IPostaWebClient_Pickup_Creation_OutputMessage">
<wsdl:part name="parameters" element="tns:Pickup_CreationResponse"/>
</wsdl:message>
<wsdl:message name="IPostaWebClient_Shipment_Creation_InputMessage">
<wsdl:part name="parameters" element="tns:Shipment_Creation"/>
</wsdl:message>
<wsdl:message name="IPostaWebClient_Shipment_Creation_OutputMessage">
<wsdl:part name="parameters" element="tns:Shipment_CreationResponse"/>
</wsdl:message>
<wsdl:message name="IPostaWebClient_Shipment_Tracking_InputMessage">
<wsdl:part name="parameters" element="tns:Shipment_Tracking"/>
</wsdl:message>
<wsdl:message name="IPostaWebClient_Shipment_Tracking_OutputMessage">
<wsdl:part name="parameters" element="tns:Shipment_TrackingResponse"/>
</wsdl:message>
<wsdl:message name="IPostaWebClient_Pickup_Cancel_InputMessage">
<wsdl:part name="parameters" element="tns:Pickup_Cancel"/>
</wsdl:message>
<wsdl:message name="IPostaWebClient_Pickup_Cancel_OutputMessage">
<wsdl:part name="parameters" element="tns:Pickup_CancelResponse"/>
.......

请按照示例 我希望有帮助