How to create SOAP 1.2 request
Asked Answered
C

2

5

I need help with creating SOAP 1.2 request. All i have is this:

SAMPLE REQUEST:

POST /WS/PriceList.asmx HTTP/1.1
Host: gateway.systemb2b.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetProducts xmlns="http://gateway.systemb2b.com/schemas/Product" />
  </soap12:Body>
</soap12:Envelope>

SAMPLE RESPONSE:

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetProductsResponse xmlns="http://gateway.systemb2b.com/schemas/Product">
      <GetProductsResult>xml</GetProductsResult>
    </GetProductsResponse>
  </soap12:Body>
</soap12:Envelope>

Thanks a lot.

Cretic answered 26/3, 2014 at 20:11 Comment(0)
H
11
<?php
    $client = new SoapClient("URL/OF/YOUR/WSDL", array('soap_version' => SOAP_1_2));
    $result = $client('GetProducts');
?>
Hasten answered 26/3, 2014 at 21:11 Comment(1)
This is the answer that I am looking for.Runstadler
B
0

I hope this example would help you to get your issue solved. All the best!

// SOAP 1.2 client
$options = array('soap_version'=>SOAP_1_2, 'exceptions'=>true, 'trace'=>1);

$client = new SoapClient('https://www.example.com/example.svc/SSL?wsdl', $options);

$actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','Action','http://tempuri.org/xxxx/GetResult');

$toActionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','To','https://www.example.com/example.svc/SSL?wsdl');

$headerbody = array('Action' => $actionHeader,'To' => $toActionHeader);
           
$client->__setSoapHeaders($headerbody);

$client->__setLocation('https://www.example.com/example.svc/SSL');

$params = array( "param1"=>"abc", "param2"=>"ab123",c"param3"=>"ab1111" );  

$client->__soapCall("GetResult", array($params));
Brythonic answered 15/7, 2020 at 9:19 Comment(1)
Welcome to SO! Please explain what your code does, otherwise no one is able to learn something and is just continuing to copy & paste which is not the goal here.Samarium

© 2022 - 2024 — McMap. All rights reserved.