Example of a SOAP request for the sf bsp order number query interface
Some interfaces sometimes use SOAP requests, such as the interfaces of sf bsp.
I tried different methods of POST requests, either completely failing to request anything or receiving garbled characters, all ended in failure.
The core code of the SOAP request for the SF interface is as follows:
The Code is as follows: |
|
/** * Send a soap request */ Private function _ soap () { $ Client = new SoapClient ($ this-> serviceUrl ); $ Info = new stdClass (); $ Info-> arg0 = $ this-> xml; $ Param = array ($ info ); $ Response = $ client->__ call ("sfexpressService", $ param ); Return $ response-> return; } /** * Concatenate the requested xml */ Public function createXml () { $ Xml = '<Request service = "RouteService" lang = "zh-CN"> <Head> '. $ this-> user.', '. $ this-> passWord.' </Head> <Body> <RouteRequest tracking_type = "1" method_type = "1" tracking_number = "'. $ this-> invoice_no.'"/> </Body> </Request> '; $ This-> xml = $ xml; } |
Tip:
1. $ this-> serviceUrl: the BSP request address allocated by SF. What are your notes? Wsdl address
2. $ this-> user, $ this-> passWord is the ID and verification code assigned by SF.
3. The returned return value is an XML String. You may need simplexml_load_string for parsing.