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

问题描述:

SOAP API集成的新手,但对PHP语言有经验。php - 使用SOAP XML与交付公司集成请求

的链接,测试一体化是在这里: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/

也有引用的数据:

我不知道如何使用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> 
+0

这不是一个代码编写的服务。你到目前为止尝试了什么?发布您的代码!当你运行它时发生了什么?你预期会发生什么?你有什么特别的问题? https://*.com/help/mcve – Robert

这是一个标准的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

看到你已经失去的可用功能:

.... 
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"/> 
....... 

,让您知道什么函数调用。 使用此代码,例如,它从一个PHP文件

<?php 

     $soapClient = new SoapClient("http://168.187.136.18:8090/APIService/PostaWebClient.svc?wsdl"); 

     // Prepare SoapHeader parameters 
     $sh_param = array( 
        'Username' => 'username', 
        'Password' => 'password'); 
     $headers = new SoapHeader('http://soapserver.example.com/webservices', 'UserCredentials', $sh_param); 

     // Prepare Soap Client 
     $soapClient->__setSoapHeaders(array($headers)); 

     // Setup the RemoteFunction parameters 
     $ap_param = array( 
        'amount'  => $irow['total_price']); 

     // Call RemoteFunction() 
     $error = 0; 
     try { 
      $info = $soapClient->__call("RemoteFunction", array($ap_param)); 
     } catch (SoapFault $fault) { 
      $error = 1; 
      print(" 
      alert('Sorry, blah returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring.". We will now take you back to our home page.'); 
      window.location = 'main.php'; 
      "); 
     } 

     if ($error == 0) {   
      $auth_num = $info->RemoteFunctionResult; 

      if ($auth_num < 0) { 
       .... 

       // Setup the OtherRemoteFunction() parameters 
       $at_param = array( 
          'amount'  => $irow['total_price'], 
          'description' => $description); 

       // Call OtherRemoteFunction() 
       $trans = $soapClient->__call("OtherRemoteFunction", array($at_param)); 
       $trans_result = $trans->OtherRemoteFunctionResult; 
      .... 
       } else { 
        // Record the transaction error in the database 

       // Kill the link to Soap 
       unset($soapClient); 
      } 
     } 
    }  
} 

?> 

只是跟随例如 我希望帮助