How to send SOAP request in curl

I'm starting a soap. How to send a request for soap? I searched on google and tried different methods, but unfortunately this did not work for me.

I really appreciated your help.

here is a sample request that i have to send:

POST /Universal/WebService.asmx HTTP/1.1 Host: www.sample.com Content-Type: text/xml;charset="utf-8" Content-Length: length SOAPAction: https://www.sample.com/Universal/WebService.asmx/Request <?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi="http://wwww.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <Request xmlns="https://www.sample.com/Universal/WebService.asmx"> <ID>CPHK01</ID> <UID>TEST</UID> <PWD>TEST</PWD> <target_mpn>09183530925</target_mpn> <amount>115</amount> <ref_no>20060830143030112</ref_no> <source_mpn>67720014</source_mpn> </Request> </soap:Body> </soap:Envelope> 

here is the answer:

  HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version = "1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://wwww.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <RequestResponse xmlns="https://www.sample.com/Universal/WebService.asmx"> <RequestResult> <Ref_no>20060830143030112</Ref_no> <StatusCode>101</StatusCode> </RequestResult> </RequestResponse> </soap:Body> </soap:Envelope> 
+4
source share
1 answer

PHP has its own SoapClient class. The constructor takes WSDL as an argument. This is preferable to cURL because SoapClient handles all the complexities of SOAP and allows you to process your own objects and arrays and eliminates the need to manually create a SOAP envelope and XML.

 try { $client = new SoapClient('https://www.sample.com/Universal/WebService.asmx?wsdl'); $response = $client->Request(array( 'ID' => 'xxxx', 'UID' => 'xxxx', 'PWD' => 'xxxx', 'target_mpn' => 'xxxx', 'amount' => 'xxxx', 'ref_no' => 'xxxx', 'source_mpn' => 'xxxx' )); print_r($response); // view the full response to see what is returned // or get the response properties: echo $response->RequestResult->Ref_no; echo $response->RequestResult->StatusCode; } catch (Exception $e) { echo $e->getMessage(); } 
+3
source

Source: https://habr.com/ru/post/1489604/


All Articles