Hi I have the fallowing soap
SOAP 1.1
POST /ServicePeletalk.asmx HTTP/1.1
Host: 82.80.225.186
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://peletop.co.il/GetProducts"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetProducts xmlns="http://peletop.co.il/">
<query>
<TerminalNum>string</TerminalNum>
<ProviderID>int</ProviderID>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<Language>Hebrew or Arabic or English</Language>
<LoadPictures>boolean</LoadPictures>
</query>
</GetProducts>
</soap:Body>
</soap:Envelope>
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://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetProductsResponse xmlns="http://peletop.co.il/">
<GetProductsResult>
<Products>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
</Products>
</GetProductsResult>
</GetProductsResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.
POST /ServicePeletalk.asmx HTTP/1.1
Host: 82.80.225.186
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://peletop.co.il/">
<query>
<TerminalNum>string</TerminalNum>
<ProviderID>int</ProviderID>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<Language>Hebrew or Arabic or English</Language>
<LoadPictures>boolean</LoadPictures>
</query>
</GetProducts>
</soap12:Body>
</soap12:Envelope>
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://peletop.co.il/">
<GetProductsResult>
<Products>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
</Products>
</GetProductsResult>
</GetProductsResponse>
</soap12:Body>
</soap12:Envelope>
how do I write it in PHP???
I tried
<?
// Maximum error reporting
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
$wsdl = 'http://82.80.225.186:8000/ServicePeletalk.asmx?WSDL';
$trace = true;
$exceptions = true;
$client = new SoapClient($wsdl, array( 'trace' => $trace, 'exceptions' => $exceptions));
$xml_array['TerminalNum'] = 5089 ;
$xml_array['UserType'] = 'SiteUser';
$xml_array['Language'] = 'English';
$xml_array['ConnectionOrDeviceID'] = '879d62-EA47-4520-8A29-EB5981A62DD8';
try
{
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->GetSellerProviders($xml_array);
}
catch (Exception $e)
{
echo "Error!";
echo $e -> getMessage ();
echo 'Last response: '. $client->__getLastResponse();
}
?>
it's not working
please help
For a first look, it seems that, based on your xml files, you have to call $client->GetProducts instead of $client->GetSellerProviders, because there is an element named GetProducts in your xml files.
If this was a typo and you really call $client->GetProducts then check for $xml_array structure to be like this
$xml_array['query']['TerminalNum'] = 5089 ;
$xml_array['query']['UserType'] = 'SiteUser';
$xml_array['query']['Language'] = 'English';
$xml_array['query']['ConnectionOrDeviceID'] = '879d62-EA47-4520-8A29-EB5981A62DD8';
include query element as shown in xml request sample.
UPDATE from comments
I see that the request xml has the following elements
<TerminalNum>string</TerminalNum>
<ProviderID>int</ProviderID>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<Language>Hebrew or Arabic or English</Language>
<LoadPictures>boolean</LoadPictures>
So the $xml_array variable should have an array with the names of these elements like:
$xml_array['query']['TerminalNum'] = 5089 ;
$xml_array['query']['ProviderID'] = 'SiteUser';
$xml_array['query']['CardType'] = 'som card type';
$xml_array['query']['Language'] = 'English';
$xml_array['query']['LoadPictures'] = 'true';
Related
I need some help to execute a SOAP request with PHP.
For example, a method for search a publisher:
POST /webservice/search.asmx HTTP/1.1
Host: www.host.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:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://host.com/HostNET/" xmlns:types="http://host.com/HostNET/encodedTypes" xmlns:rpc="http://www.w3.org/2003/05/soap-rpc" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body soap12:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<tns:findPublishers>
<sessionToken xsi:type="xsd:string">string</sessionToken>
<expression soapenc:id="id0" xsi:type="tns:SearchExpression">
<expression xsi:type="xsd:string">string</expression>
<phonetic xsi:type="xsd:boolean">boolean</phonetic>
<inflections xsi:type="xsd:boolean">boolean</inflections>
</expression>
<distributeurs xsi:type="xsd:boolean">boolean</distributeurs>
</tns:findPublishers>
</soap12:Body>
</soap12:Envelope>
I have the sessionToken but I don't understand what I have to do with the line <expression soapenc:id="id0" xsi:type="tns:SearchExpression"> and it's contents.
try{
$search = new SoapClient("http://www.host.com/WebService/search.asmx?wsdl", array("soap_version" => SOAP_1_2));
$search->findPublishers($sessionToken,???????,FALSE);
}catch (SoapFault $e){
print_r($e);
}
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.
<?php
$client = new SoapClient("URL/OF/YOUR/WSDL", array('soap_version' => SOAP_1_2));
$result = $client('GetProducts');
?>
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));
As I am pretty new to SOAP I really need some help to get started. I have been given this structur:
request:
POST /NumbriParing/NumbriParing.asmx HTTP/1.1
Host: nba.tja.ee
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://nba.sa.ee/NumriomanikuParing"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NumriomanikuParing xmlns="http://nba.sa.ee/">
<number>long</number>
</NumriomanikuParing>
</soap:Body>
</soap:Envelope>
Response:
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://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NumriomanikuParingResponse xmlns="http://nba.sa.ee/">
<NumriomanikuParingResult>
<Number>long</Number>
<OmanikuRegNumber>string</OmanikuRegNumber>
<Omanik>string</Omanik>
<VastusKood>NumberLeitud or NumbritEiLeitud</VastusKood>
</NumriomanikuParingResult>
</NumriomanikuParingResponse>
</soap:Body>
</soap:Envelope>
I need to replace the "long" placeholder in the request with a numeric variable to get the request for that number.
The asmx is located in https://nba.tja.ee/NumbriParing/NumbriParing.asmx
How Can it be done using php?
Best regards,
Martti
Use SoapClient and WSDL of the service you need.
Something like:
try {
$client = new SoapClient('https://nba.tja.ee/NumbriParing/NumbriParing.asmx?WSDL');
$param = new stdClass();
$param->number = 123;
$result = $client->NumriomanikuParing($param);
var_dump($result);
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
The following is a sample SOAP 1.1 request and response.:
POST /atservices/1.5/atws.asmx HTTP/1.1
Host: webservices2.autotask.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://autotask.net/ATWS/v1_5/getZoneInfo"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getZoneInfo xmlns="http://autotask.net/ATWS/v1_5/">
<UserName>string</UserName>
</getZoneInfo>
</soap:Body>
</soap:Envelope>
we want to call web services of autotask using soap in php.can we get example for it
how we should call soap client.
Its output should be like this :
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://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getZoneInfoResponse xmlns="http://autotask.net/ATWS/v1_5/">
<getZoneInfoResult>
<URL>string</URL>
<ErrorCode>int</ErrorCode>
<DataBaseType>string</DataBaseType>
<CI>int</CI>
</getZoneInfoResult>
</getZoneInfoResponse>
</soap:Body>
</soap:Envelope>
Use the PHP native SoapClient along with the service WSDL, like so:
$atservices_wsdl = "https://www.autotask.net/atservices/1.5/atws.wsdl";
$atservices_client = new SoapClient($atservices_wsdl);
$zone_info = $atservices_client->getZoneInfo("SomeUserName");
print_r($zone_info); // review the returned object converted from SOAP response.
echo $zone_info->DataBaseType; // this might work if it's not behind a Response object.
At the very least, you should be aiming for something like this. More can be found here.
$soap = new SoapClient('link/to/.wsdl');
$result = $soap->__soapCall('getZoneInfo', array('UserName' => $username));
var_dump($result);
Hello i need to connect to SOAP web services with password, username and SourceId in php.
the SOAP request is:
POST /webservices/AgentOnlineReservation.asmx HTTP/1.1
Host: 54.228.189.53
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetHotelsData"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetHotelsData xmlns="http://tempuri.org/">
<SourceId>string</SourceId>
<UserName>string</UserName>
<Password>string</Password>
</GetHotelsData>
</soap:Body>
</soap:Envelope>
Please help me.
Use the native SoapClient library:
$client = new SoapClient('linkhere.com/AgentOnlineReservation.asmx?wsdl');
$response = $client->GetHotelsData(array(
'SourceId' => '...',
'UserName' => '...',
'Password' => '...'
));
print_r($response);
The link passed in the SoapClient call is the WSDL (Web Service Description Language) file.