Home
Instructions for access in PHP
Contents
1. Service gt 64 7 Communication array Email gt test test ch T FreeText1 Free Text 1 FreeText2 gt Free Text 2 Language gt DE Add addtional items here for multiple requests in one veb service call array 2 Item same structure as above UE Setting attribute of notification notification generateLabelRequest gt Data gt Provider Sending Item 0 Notification notification Type EMAIL 2 Web service call response null try response SOAP Client gt GenerateLabel generateLabelRequest catch SoapFault fault echo Error in GenerateLabel fault gt toString br 3 Process requests save label images and check for errors see documentation of structure in Barcode web service manual foreach getElements response gt Envelope gt Data gt Provider gt Sending gt Item as item if item gt Errors null Error in Label Request Item This barcode label was not generated due to errors The received error messages are returned in the specified language of the request 15 This means that the label was not generated but other labels from other request items in same call might have been generated successfully anyway SerrorMessages Sdelimiter foreach g
2. CH Phone gt 0313381111 f r ZAW3213 Mobile gt 0793381111 EMail gt h musterepost ch LabelAddress gt array LabelLine gt array LabelLine 1 LabelLine 2 LabelLine 3 LabelLine 4 LabelLine 5 LA AdditionalINFOS gt array Cash On Cary amount in CHF for service BLN with or without spaces AdditionalData gt array Type gt NN BETRAG Value gt 12 5 he Cash On Cary ESR Reference No for service BLN AdditionalData array Type gt NN ESR REF REFNR Value gt xxxxxxxxxxxxxxxxxxxxxx a valid ESR z Ls Attributes gt array PRZL gt array At least one code is required schema validation Basic service code s optional default ECO PRI Additional service codes optional N FRA Delivery instruction codes optional ZAN3211 ZAN3213 Cash on delivery amount in CHF for service N Amount 12 5 FreeText gt Freitext DeliveryDate gt 2010 06 19 ParcelNo gt 2 ParcelTotal gt 5 DeliveryPlace gt Vor der Haust re ProClima gt true Setting notifications Notification gt array
3. Envelope gt array LabelDefinition gt array LabelLayout gt A5 Data gt array Provider gt array Sending gt array Item gt array array 1 Item VItemID 1 Attributes gt array PRZL gt array At least on Additional service codes FRA NOTA Delivery instruction codes ZAW3213 ZAW3215 code is required schema validation Basic service code s optional default ECO optional optional Add additional items here for multiple requests in one web service call array 2 Item same structure as above FL 3 2 Web service call try Sresponse SOAP Client gt ValidateCombination validationRequest 11 catch SoapFault fault echo Error in ValidateCombination fault toString br 3 Process response see documentation of structure in Barcode web service manual foreach getElements response gt Envelope gt Data gt Provider gt Sending gt Item as item if item Errors null Errors in validation error messages are returned in the requested language SerrorMessages foreach getElements item gt Errors gt Error as error SerrorMessages error sMessage echo lt p gt Validation ERROR for item with itemID item
4. generateBarcodeRequest array Language gt de BarcodeDefinition gt array BarcodeType gt LSO 2 ImageFileType gt PNG ImageResolution gt 200 2 Web service call response null try response SOAP Client GenerateBarcode generateBarcodeRequest catch SoapFault fault echo Error in GenerateBarcode fault gt toString br 3 Process requests save label images and check for errors see documentation of structure in Barcode web service manual foreach getElements response Data as data if data gt Errors null Error in Barcode Request Item This barcode label was not generated due to errors The received error messages are returned in the specified language of the request This means that the label was not generated but other labels from other request items in same call might have been generated successfully anyway SerrorMessages Sdelimiter foreach getElements data sErrors sError as error SerrorMessages delimiter error sMessage Sdelimiter echo lt p gt ERROR for request errorMessages br p 21 else Get successfully generated barcide as binary data barcodeBinaryData data gt Barcode deliveryNoteRef data DeliveryNoteRef SbarcodeDefinition data sBarcodeDefinition SbarcodeT
5. Name2 gt Generalagentur Street gt Viktoriaplatz 10 POBox gt Postfach 600 ALP gt 780507 HEGIZ Zurich Country gt CH DomicilePostOffice gt 3000 Bern da Data gt array Provider gt array Sending gt array Item gt array array 1 Item ItemID gt 1234 ItemNumber gt 12345678 IdentCode gt 1234 Recipient gt array PostIdent gt IdentCodeUser miele Frau Vorname gt Melanie Namel gt Steiner Name2 gt M ller AG Street gt Viktoriastrasse HouseNo gt 21 FloorNo gt 1 MailboxNo gt 1111 17 WIP 3030 City gt Bern 1 Country gt CH Phone gt 0313381111 f r ZAW3213 Mobile gt 0793381111 EMail gt h muster post ch LabelAddress gt array LabelLine gt array LabelLine 1 LabelLine 2 LabelLine 3 74 LabelLine 4 LabelLine 5 r AdditionalINFOS gt array Cash On Cary amount in CHF for service BLN AdditionalData gt array Type gt NN BETRAG BEA Value gt 12 5 ja Cash
6. Barcode web service Instructions for access in PHP Version 2 2 November 2013 SWISS 1 Table of contents 1 Introduction 2 Configuration 2 1 WSDL files 2 2 SOAPClient configuration 2 3 Proxy configuration 2 4 Encoding character set 3 Read operations 4 Validation operation 5 Label generation 6 Single Barcodes Generation 7 Individual Barcodes Generation References 1 Barcode web service manual http www swisspost ch post barcode handbuch pdf 2 Documentation about Barcode web service http vvvvvv svvisspost ch post barcode cug htm uu b A 11 13 17 21 1 Introduction This documentation explains how to use the Barcode web service in PHP The use of the web service is explained by means of a number of typical examples This documentation is not intended to provide a complete specification of the web service interface but simply contains instructions on how the web service can be used in PHP For full documentation of the Barcode web service please refer to the Web Service User Manual 1 which also explains all the terms attributes service codes etc Additional resources and tools for the Barcode web service can be found on the Barcode web service homepage 2 All examples are also available as php sources The examples illustrated here use a couple of simple aids that are available in the wsbc utils php file 2 Configuration The SOAPClient php has a pr
7. exit echo ul echo lt li gt Label Layouts elements echo ul foreach getElements labelLayoutsResponse gt LabelLayout as labelLayout echo li echo 1abelLayout LabelLayout echo max labelLayout sMaxServices services echo and 1abelLayout MaxDeliveryInstructions delivery instructions if labelLayout gt FreeTextAllowed echo freetext allowed else echo freetext not allowed echo lt li gt echo lt ul gt elements echo lt li gt echo lt ul gt 2 1 3 echo lt li gt echo lt ul gt ebr s ebi Webr s ch1 gt Allowed Services By Franking License XXXXX lt h1 gt 3 Read allowed services by franking license SallowedServicesRequest array FrankingLicense gt XXXXX Language gt de try SallowedServicesResponse SOAP Client gt ReadAllowedServicesByFrankingLicense SallowedServicesRequest catch SoapFault fault echo Error in ReadAllowedServicesByFrankingLicense fault toString br i exit echo suls foreach getElements allovedServicesResponse sServiceGroups as serviceGroup echo li echo ServiceGroup serviceGroup ServiceGroup ServiceGroupID serviceGroup sServiceGroup sDescription echo culs foreach getElements
8. ItemID SerrorMessages br p else Successful validation echo p Validation was successfull for service code combination in item with itemID item ItemID br p Also display warnings if item gt Warnings null varningMessages foreach getElements item gt Warnings gt Warning as warning varningMessages warning Message echo with WARNINGS warningMessages br echo body html This example validates without errors If however for example ZAW3215 is replaced with ZAW3222 the web service request replies with a correspond ing validation error message This example is available in the wsbc validate php file 12 5 Label generation The following example demonstrates how an individual address label can be generated in php and the response read The address label generated is saved in an image file include wsbc init php include wsbc utils php Franking License Configuration TODO you have to set this to a valid franking license for your barcode web service user account frankinglicense 1234567890 Simgfile default logo gif 1ogo binary data fread fopen imgfile r filesize imgfile 1 Define Label Request see documentation of structure in Barcode veb service manual generateLabelRequest array Language gt de Envelope gt
9. array LabelDefinition gt array LabelLayout gt A5 PrintAddresses gt RecipientAndCustomer ImageFileType gt GIF ImageResolution gt 300 PrintPreview gt false da FileInfos gt array FrankingLicense gt frankinglicense PpFranking gt false Customer gt array Namel gt Meier AG Name2 gt Generalagentur Street gt Viktoriaplatz 10 POBox gt Postfach 600 21 D B City gt Z rfieh Country gt CH Logo gt 1ogo binary data LogoFormat gt GIF DomicilePostOffice gt 3000 Bern CustomerSystem PHP Client System Me Data gt array Provider gt array Sending gt array Item gt array array 1 Item ItemID gt 1234 ItemNumber gt 12345678 IdentCode gt 1234 Recipient gt array PostIdent gt IdentCodeUser 13 14 Title gt Frau Vorname gt Melanie Namel gt Steiner Name2 gt M ller AG Street gt Viktoriastrasse HouseNo gt 21 FloorNo gt 1 MailboxNo gt 1111 ZIP 3030 City gt Bern 1 Country gt
10. serviceGroup sBasicService as basicService echo lt li gt przls count basicService gt PRZL if przls 1 echo BasicService basicService Description toCommaSeparatedString SbasicService PRZL else echo BasicService basicService sDescription basicService PRZL echo lt li gt echo lt ul gt echo li echo br echo ul echo lt body gt lt html gt This example is available in the wsbc read php file 10 4 Validation operation The web service makes an operation available in order to validate a combination of service codes The system checks that the service codes contained in the request basic service additional services and delivery instructions can be combined The system also checks whether the codes used are permitted in the chosen label format A5 A6 or A7 Only a certain number of service codes and delivery instructions are permitted depend ing on the format The following example demonstrates a check on a combination of basic service codes additional service codes and delivery instruction codes include wsbc init php include wsbc utils php echo lt html gt lt header gt lt header gt lt body gt 1 Define Validation Request see documentation of structure in Barcode web service manual SvalidationRequest array Language gt de
11. On Cary ESR Reference No for service BLN AdditionalData gt array Type gt NN ESR REF REFNR Value gt xxxxxxxxxxxxxxxxxxxxxx a valid ESR Ref Nr with or without spaces DAE Attributes gt array PRZL gt array At least one code is required schema validation SAR RING ZAW2511 E Cash on delivery amount in CHF for service N Amount gt 12 5 FreeText gt Freitext DeliveryDate gt 2010 06 19 ParcelNo gt 2 ParcelTotal gt 5 DeliveryPlace gt Vor der Haust re ProClima gt true Notification gt array Notification structure Add additional items here for multiple requests in one veb service call array 2 Item same structure as above 2 Web service call response null try response SOAP Client GenerateSingleBarcodes generateSingleBarcodesRequest catch SoapFault fault echo Error in GenerateSingleBarcodes fault gt toString br 3 Process requests save label images and check for errors see documentation of structure in Barcode web service manual foreach getElements response gt Envelope gt Data gt Provider gt Sending gt Item as item if item gt Errors null Error in Single Request Item Thi
12. alServices fault gt toString br exit echo ul echo li Additional service codes delimiter foreach getElements additionalServicesResponse sAdditionalService as additionalService echo delimiter additionalService PRZL delimiter echo li echo lt ul gt ds 2 1 2 Delivery instructions for basic service deliveryInstructionsRequest array Language gt de PRZL gt SbasicServiceCodes try deliveryInstructionsResponse SOAP Client ReadDeliveryInstructions SdeliveryInstructionsRequest catch SoapFault fault echo Error in ReadDeliveryInstructions fault gt toString br exit echo lt ul gt echo li Delivery instruction codes delimiter foreach getElements deliveryInstructionsResponse gt DeliveryInstructions as deliveryInstruction echo delimiter deliveryInstruction gt PRZL Sdelimiter echo lt li gt echo lt ul gt 2 1 2 2 1 3 Label layouts for basic service labelLayoutsRequest array Language gt de PRZL gt basicServiceCodes try labelLayoutsResponse SOAP Client gt ReadLabelLayouts SlabelLayoutsRequest echo echo echo echo echo catch SoapFault fault echo Error in ReadLabelLayouts fault toString br
13. atch SoapFault fault echo Error in ReadServiceGroups fault toString br exit echo 1 4 Services Test Execution lt h1 gt echo br echo br 2 For each service group read and display service codes and label layouts foreach getElements serviceGroupsResponse sServiceGroup as group echo lt b gt Available service codes and layouts for Service Group group Description c b echo br echo br 2 1 Basic services for service group SbasicServicesRequest array Language gt de ServiceGroupID gt group gt ServiceGroupID try basicServicesResponse SOAP Client gt ReadBasicServices basicServicesRequest catch SoapFault fault echo Error in ReadBasicServices fault gt toString br exit echo Basic Services echo ul foreach getElements basicServicesResponse gt BasicService as basicService echo lt li gt basicServiceCodes getElements basicService gt PRZL echo toCommaSeparatedString basicServiceCodes 2 1 1 Additional services for basic service SadditionalServicesRequest array Language gt de PRZL gt SbasicServiceCodes try 1 SadditionalServicesResponse SOAP Client gt ReadAdditionalServices SadditionalServicesRequest catch SoapFault fault echo Error in ReadAdditon
14. c barcode v2 2 Webservice Barcode Login login gt Susername password gt password Encoding for Strings encoding gt ISO 8859 1 Optional Proxy Config if you are behind a proxy proxy host gt proxy mydomain com proxy port gt 8080 Optional Proxy Authentication if your proxy needs a username and password proxy login gt proxy username proxy password gt proxy passvord Addtional debug trace information trace gt true Connection timeout in seconds connection timeout gt 90 SOAP Client Initialization try SOAP Client new SoapClient SOAP wsdl file path SOAP config catch SoapFault fault echo Error in SOAP Initialization fault gt toString br exit A sample configuration can also be found in the wsbc init php 24 Encoding character set file that is incorporated in all the other examples n order for the examples to vvork a valid username and passvvord for access to the Barcode vveb service must be entered in the configuration All the examples below assume that a corresponding SOAPClient has first been correctly initialized Any proxy for access to the Internet must be properly configured in the SOAP_config array See the commented out lines in the previous example in section 2 2 The SOAPClient can be configured to work with character set enco
15. ding other than UTF 8 To do this see the encoding setting in the previous example in section 2 2 This setting means that all the strings passed in the encoding set are expected and duly converted to UTF 8 All return values are also converted back by UTF 8to the character set duly set In this setting therefore you should if possible set the encoding that is used in the php sources to avoid the strings having to be constantly encoded The php sample sources that are also supplied are coded in UTF 8 which is why this setting is not included in the examples 3 Read operations The read operations can be used to call up all the service codes and label layouts of the web service that are currently supported The following php example illustrates how all these read operations are used The example illustrates a handful of all the service codes and label layouts currently available in HTML include wsbc init php include wsbc utils php covered requests 1 ReadServiceGroups 2 1 ReadBasicServices 2 1 1 ReadAdditionalServices 2 1 2 ReadDeliveryInstructions 2 1 3 ReadLabelLayouts 3 ReadAllowedServicesByFrankingLicense echo lt html gt lt header gt lt header gt lt body gt 1 Read all service groups serviceGroupsRequest array Language gt de try serviceGroupsResponse SSOAP Client gt ReadServiceGroups serviceGroupsRequest c
16. etElements item gt Errors gt Error as error SerrorMessages delimiter error sMessage Sdelimiter echo lt p gt ERROR for item with itemID item gt ItemID SerrorMessages br p else Get successfully generated label as binary data SidentCode item gt IdentCode labelBinaryData item gt Label Save the binary image data to image file filename outputfolderNtestOutput GenerateLabel identCode gif file put contents filename labelBinaryData Printout some label information and warnings if any echo lt p gt Label generated successfully for identCode identCode br if item gt Warnings null SwarningMessages foreach getElements item gt Warnings gt Warning as warning warningMessages warning Message echo with WARNINGS warningMessages br echo filename br img src S filename br echo lt p gt echo lt body gt lt html gt Important Note on the Operation GenerateLabel n order for the above example to work a valid franking Various other fields may be placed in a GenerateLabelRequest licence must always be set for the Login web service being Please refer to the complete documentation on the Barcode used web service 1 in particular section 4 3 1 Should an item in a response contain one or more errors it means that th
17. is address label could not be generated The sample file wsbc generate php also contains the above However it may be that other address labels in the same example with additional comments on all the optional fields that request were correctly generated can be additionally set Even if an address label was successfully generated it may that the item contains warnings This is most likely if for instance parameters that are not required for the chosen services were entered 16 6 Single Barcodes Generation The following example demonstrates how several barcode elements of the function GenerateSingleBarcodes can be generated in PHP and the response read out The generated barcode elements are saved as image files include wsbc init php include wsbc utils php Franking License Configuration TODO you have to set this to a valid franking license for your barcode web service user account frankinglicense 1234567890 1 Define Label Request see documentation of structure in Barcode veb service manual generateSingleBarcodesRequest array Language gt de Envelope gt array BarcodeDefinition gt array ImageFileType gt PNG ImageResolution gt 300 q FileInfos gt array FrankingLicense gt frankinglicense PpFranking gt false Customer gt array Namel gt Meier AG
18. oblem with accessing WSDL files via proxies We therefore strongly advise that you save the WSDL file and associated XSD file locally for access from php To do this download the following two XML files and save them under the file names provided in a directory that can be accessed in php For the following examples we have assumed that these files are in the same directory as the php sources For the following examples it is assumed that these files are located in the same directory as the PHP source files URL for download Save under file name http www post ch post barcode description service wsdl barcode_v2_2 wsdl http vvvvvv post ch barcode v2 2 xsd barcode v2 2 xsd ATTENTION Both files must be located in the same directory and the file barcode v2 2 xsd must bear this exact name since this file is integrated in the WSDL file These files are also contained in the php example sources The web service is accessed via a SOAPClient instance The following example illustrates the initialization of the SOAPClient object for accessing the Barcode web service The parameters that have been commented out are optional and can be used if needed SOAP Configuration Susername your username Spassword your password Sendpoint_url http anylocationURL v2_2 SOAP wsdl file path barcode v2 2 wsdl SOAP config array Webservice Endpoint URL location gt https wsbc post ch wsb
19. red for the selected services 22 Post CH Ltd Support Webservices Viktoriastrasse 21 P O Box 3030 Berne Switzerland webservice post ch www swisspost ch webservice SWISS POST 12 11 2013
20. s barcode label was not generated due to errors The received error messages are returned in the specified language of the request This means that the label was not generated but other labels from other request items in same call might have been generated successfully anyway SerrorMessages Sdelimiter foreach getElements item gt Errors gt Error as error SerrorMessages delimiter error gt Message Sdelimiter echo lt p gt ERROR for item with itemID item gt ItemID SerrorMessages br p else Get successfully generated label as binary data SitemID item gt IdentID SidentCode item gt IdentCode Scounter 1 SbasePath output folder testOutput_GenerateSingleBarcodes identCode foreach getElements item sBarcodes sBarcode as barcode Save the binary image data to image file filename basePath counter gif file_put_contents filename barcode Scounter SnumberOfItems counter 1 Printout some label information and varnings if any echo p numberOfItems Barcodes successfully generated for identCode identCode lt br gt if item gt Warnings null SwarningMessages foreach getElements item Warnings Warning as warning warningMessages warning Message echo with WARNINGS warningMessages br echo All files start wi
21. th lt br gt lt img src basePath br echo lt p gt echo body html Important Information on the Operation GenerateLabel in order for the example above to function properly a valid franking licence for the applicable web service login must be set Should an item in a GenerateSingleBarcodes response contain one or more errors it means that barcode elements could not be generated The response item may contain warnings even when the bar code elements were successfully generated This is especially likely when for example parameters were consigned that were not required for the selected services 20 In a GenerateSingleBarcodes request various other fields can be set We refer you to the full documentation Webservice Barcodes 1 specifically to Section 4 3 x Additionally you will find in the sample file wsbc generate singlebarcodes php the above example with additional comments and all further optional fields that can be set 7 Individual Barcodes Generation The following example demonstrates how individual barcodes can be generated in PHP using the function GenerateBarcodes and the response read out The barcodes are saved as image files include wsbc init php include wsbc utils php echo lt html gt lt header gt lt header gt lt body gt 1 Define Label Request see documentation of structure in Barcode web service manual
22. ype barcodeDefinition BarcodeType SimageFileType barcodeDefinition gt ImageFileType SimageResolution barcodeDefinition ImageResolution Save the binary image data to image file filename outputfolderNtestOutput GenerateBarcode deliveryNoteRef gif file put contents filename barcodeBinaryData Printout some label information and varnings if any echo lt p gt Label generated successfully for Delivery Note Reference deliveryNoteRef lt br gt if data Warnings null warningMessages foreach getElements data gt Warnings gt Warning as warning warningMessages warning Message echo with WARNINGS warningMessages br echo filename br img src S filename br echo lt p gt echo lt body gt lt html gt Important Information on the Operation GenerateBarcode Should a data object in a GenerateBarcode response contain For further information we refer you to the full documentation one or more errors it means that this barcode could not be Webservice Barcodes 1 specifically to Section 4 3 x generated The response data object may contain warnings even when Additionally you will find the above example in the sample file the barcode was successfully generated This is especially likely vvsbc generatebarcode php when for example parameters were consigned that were not requi
Download Pdf Manuals
Related Search
Related Contents
Blue Rhino GBC730W-C Outdoor Kitchen Island User Manual Pro 3600 DIY User Manual - Brigham Young University DVI VGA USB KVM Switch Betriebsanleitung GasPen DIGITAL deutsch - schuetz user manual topview user manual topview DECT Sagemcom SIXTY - Web User Guide EN (AU_NZ) JVC TK-C750E surveillance camera Belinea 101915 19" TFT 株式会社 アニモ 周波数調整器ユニット単体 取扱説明書 Copyright © All rights reserved.
Failed to retrieve file