Sepp Maier Sepp Maier - 3 months ago 26
PHP Question

PHP SOAP shippinglabelservice

I would like to create shippinglabels after successfull order in my webshop. My local parcelservice has a webservice which uses SOAP. But they can not provide me a understandable codeexample.

A working XML request looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org

/soap/envelope/" xmlns:post="http://post.ondot.at" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:core="http://Core.Model" xmlns:ser="http://schemas.microsoft.com/2003/10/Serialization/">
<soapenv:Header/>
<soapenv:Body>
<post:ImportShipment>
<!--Optional:-->
<post:row>
<post:ClientID>xxx</post:ClientID>
<post:ColloList>
<post:ColloRow>
<post:Weight>5</post:Weight>
</post:ColloRow>
</post:ColloList>
<post:CustomDataBit1>false</post:CustomDataBit1>
<post:DeliveryServiceThirdPartyID>10</post:DeliveryServiceThirdPartyID>
<post:FeatureList>
</post:FeatureList>
<post:OURecipientAddress>
<post:AddressLine1>Teststrasse</post:AddressLine1>
<post:AddressLine2/>
<post:City>Wien</post:City>
<post:CountryID>AT</post:CountryID>
<post:Email></post:Email>
<post:HouseNumber>1</post:HouseNumber>
<post:Name1>Test Recipient</post:Name1>
<post:PostalCode>1030</post:PostalCode>
</post:OURecipientAddress>
<post:OUShipperAddress>
<post:AddressLine1>xxx</post:AddressLine1>
<post:City>xxx</post:City>
<post:CountryID>AT</post:CountryID>
<post:Name1>xxx</post:Name1>
<post:Name2></post:Name2>
<post:PostalCode>xx</post:PostalCode>
</post:OUShipperAddress>
<post:OrgUnitGuid>xxx</post:OrgUnitGuid>
<post:OrgUnitID>xxx</post:OrgUnitID>
<post:PrinterObject>
<post:LabelFormatID>100x200</post:LabelFormatID>
<post:LanguageID>pdf</post:LanguageID>
<post:PaperLayoutID>2xA5inA4</post:PaperLayoutID>
</post:PrinterObject>
</post:row>
</post:ImportShipment>
</soapenv:Body>
</soapenv:Envelope>


The Serviceaddress is: http://plctest.post.at/DataService/Post.Webservice/ShippingService.svc?wsdl

So I tried:

$client = new SoapClient('http://plctest.post.at/DataService/Post.Webservice/ShippingService.svc?wsdl');
$result = $client->ImportShipment($params);


But I do not know how to format $params based on the XML.

Any assistance would be great.
Thanks.

Answer
    try{
        $client     = new SoapClient("http://plctest.post.at/DataService/Post.Webservice/ShippingService.svc?wsdl");
        echo "<pre>";
        var_dump($client->__getFunctions());
        var_dump($client->__getTypes());
        echo "</pre>";
   }catch(Exception $e){
        echo $e->getMessage();
    }

You check functions and parameters above code this like. So output :


    array(10) {
      [0]=>
      string(65) "ImportShipmentResponse ImportShipment(ImportShipment $parameters)"
      [1]=>
      string(98) "ImportShipmentReturnImageResponse ImportShipmentReturnImage(ImportShipmentReturnImage $parameters)"
      [2]=>
      string(62) "ImportAddressResponse ImportAddress(ImportAddress $parameters)"
      [3]=>
      string(68) "PerformEndOfDayResponse PerformEndOfDay(PerformEndOfDay $parameters)"
      [4]=>
      string(68) "CancelShipmentsResponse CancelShipments(CancelShipments $parameters)"
      [5]=>
      string(65) "ImportShipmentResponse ImportShipment(ImportShipment $parameters)"
      [6]=>
      string(98) "ImportShipmentReturnImageResponse ImportShipmentReturnImage(ImportShipmentReturnImage $parameters)"
      [7]=>
      string(62) "ImportAddressResponse ImportAddress(ImportAddress $parameters)"
      [8]=>
      string(68) "PerformEndOfDayResponse PerformEndOfDay(PerformEndOfDay $parameters)"
      [9]=>
      string(68) "CancelShipmentsResponse CancelShipments(CancelShipments $parameters)"
    }
    array(33) {
      [0]=>
      string(40) "struct ArrayOfstring {
     string string;
    }"
      [1]=>
      string(8) "int char"
      [2]=>
      string(17) "duration duration"
      [3]=>
      string(11) "string guid"
      [4]=>
      string(85) "struct ArrayOfShipmentDocumentEntry {
     ShipmentDocumentEntry ShipmentDocumentEntry;
    }"
      [5]=>
      string(106) "struct ShipmentDocumentEntry {
     int DocumentID;
     int ID;
     string Number;
     int Quantity;
     int ShipmentID;
    }"
      [6]=>
      string(41) "struct EntityBase {
     ID Id;
     IDREF Ref;
    }"
      [7]=>
      string(43) "struct ImportShipment {
     ShipmentRow row;
    }"
      [8]=>
      string(781) "struct ShipmentRow {
     AddressRow AlternativeReturnOrgUnitAddress;
     ArrayOfstring BusinessDocumentEntryList;
     int ClientID;
     ArrayOfColloRow ColloList;
     string CostCenterThirdPartyID;
     boolean CustomDataBit1;
     boolean CustomDataBit2;
     string CustomsDescription;
     string DeliveryInstruction;
     string DeliveryServiceThirdPartyID;
     ArrayOfAdditionalInformationRow FeatureList;
     string MovementReferenceNumber;
     string Number;
     AddressRow OURecipientAddress;
     AddressRow OUShipperAddress;
     string OUShipperReference1;
     string OUShipperReference2;
     guid OrgUnitGuid;
     int OrgUnitID;
     PrinterRow PrinterObject;
     int ReturnDays;
     int ReturnModeID;
     int ReturnOptionID;
     ArrayOfShipmentDocumentEntry ShipmentDocumentEntryList;
     dateTime ShippingDateTimeFrom;
     dateTime ShippingDateTimeTo;
    }"
      [9]=>
      string(379) "struct AddressRow {
     string AddressLine1;
     string AddressLine2;
     string City;
     string CountryID;
     string EORINumber;
     string Email;
     string Fax;
     string Homepage;
     string HouseNumber;
     string Name1;
     string Name2;
     string Name3;
     string Name4;
     string PersonalTaxNumber;
     string PostalCode;
     string ProvinceCode;
     string Tel1;
     string Tel2;
     string ThirdPartyID;
     string VATID;
    }"
      [10]=>
      string(46) "struct ArrayOfColloRow {
     ColloRow ColloRow;
    }"
      [11]=>
      string(152) "struct ColloRow {
     ArrayOfColloArticleRow ColloArticleList;
     ArrayOfColloCodeRow ColloCodeList;
     int Height;
     int Length;
     decimal Weight;
     int Width;
    }"
      [12]=>
      string(67) "struct ArrayOfColloArticleRow {
     ColloArticleRow ColloArticleRow;
    }"
      [13]=>
      string(260) "struct ColloArticleRow {
     string ArticleName;
     string ArticleNumber;
     decimal ConsumerUnitNetWeight;
     string CountryOfOriginID;
     string CurrencyID;
     int CustomsOptionID;
     string HSTariffNumber;
     decimal Quantity;
     string UnitID;
     decimal ValueOfGoodsPerUnit;
    }"
      [14]=>
      string(58) "struct ArrayOfColloCodeRow {
     ColloCodeRow ColloCodeRow;
    }"
      [15]=>
      string(87) "struct ColloCodeRow {
     string Code;
     int NumberTypeID;
     string OUCarrierThirdPartyID;
    }"
      [16]=>
      string(94) "struct ArrayOfAdditionalInformationRow {
     AdditionalInformationRow AdditionalInformationRow;
    }"
      [17]=>
      string(121) "struct AdditionalInformationRow {
     string ThirdPartyID;
     string Value1;
     string Value2;
     string Value3;
     string Value4;
    }"
      [18]=>
      string(105) "struct PrinterRow {
     string Encoding;
     string LabelFormatID;
     string LanguageID;
     string PaperLayoutID;
    }"
      [19]=>
      string(179) "struct ImportShipmentResponse {
     ArrayOfColloRow ImportShipmentResult;
     string zplLabelData;
     string pdfData;
     string shipmentDocuments;
     string errorCode;
     string errorMessage;
    }"
      [20]=>
      string(54) "struct ImportShipmentReturnImage {
     ShipmentRow row;
    }"
      [21]=>
      string(188) "struct ImportShipmentReturnImageResponse {
     ArrayOfColloRow ImportShipmentReturnImageResult;
     ArrayOfstring imageData;
     string shipmentDocuments;
     string errorCode;
     string errorMessage;
    }"
      [22]=>
      string(104) "struct ImportAddress {
     int clientID;
     int orgUnitID;
     guid orgUnitGuid;
     ArrayOfAddressRow addresses;
    }"
      [23]=>
      string(52) "struct ArrayOfAddressRow {
     AddressRow AddressRow;
    }"
      [24]=>
      string(73) "struct ImportAddressResponse {
     string errorCode;
     string errorMessage;
    }"
      [25]=>
      string(76) "struct PerformEndOfDay {
     int clientID;
     int orgUnitID;
     guid orgUnitGuid;
    }"
      [26]=>
      string(106) "struct PerformEndOfDayResponse {
     string PerformEndOfDayResult;
     string errorCode;
     string errorMessage;
    }"
      [27]=>
      string(63) "struct CancelShipments {
     ArrayOfCancelShipmentRow shipments;
    }"
      [28]=>
      string(73) "struct ArrayOfCancelShipmentRow {
     CancelShipmentRow CancelShipmentRow;
    }"
      [29]=>
      string(124) "struct CancelShipmentRow {
     int ClientID;
     ArrayOfstring ColloCodeList;
     string Number;
     guid OrgUnitGuid;
     int OrgUnitID;
    }"
      [30]=>
      string(86) "struct CancelShipmentsResponse {
     ArrayOfCancelShipmentResult CancelShipmentsResult;
    }"
      [31]=>
      string(82) "struct ArrayOfCancelShipmentResult {
     CancelShipmentResult CancelShipmentResult;
    }"
      [32]=>
      string(115) "struct CancelShipmentResult {
     boolean CancelSuccessful;
     string ErrorCode;
     string ErrorMessage;
     string Number;
    }"
    }

Find your function and its parameters and call the function with __soapCall

Edit :

You call the function's paramaters this web service singleWsdl you show it:

http://plctest.post.at/DataService/Post.Webservice/ShippingService.svc?singleWsdl

Comments