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';
How to send PHP SOAP Request to .NET Web Services, I have already tried soapclient(); class but something wrong..... any body please help me.
POST /KH/TestKH/WebServices.asmx HTTP/1.1
Host: www.host.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/SearchMethod"
<?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>
<SearchMethod xmlns="http://tempuri.org/">
<_hap>string</_hap>
<_hapType>string</_hapType>
<UserID>string</UserID>
<Password>string</Password>
<Origin>string</Origin>
<Destination>string</Destination>
<FromDate>string</FromDate>
<ToDate>string</ToDate>
<Class>string</Class>
<Airlines>string</Airlines>
<Adults>int</Adults>
<Childs>int</Childs>
<Infants>int</Infants>
<isReturn>boolean</isReturn>
<CompanyCode>string</CompanyCode>
<sessionId>string</sessionId>
</SearchMethod>
</soap:Body>
</soap:Envelope>
OUR CODE:
$options["soap_version"]=SOAP_1_1;
$options["trace"]=true;
$options["exceptions"]=0;
$options["UserID"]="xxxxx";
$options["Password"]="xxxxx";
$client = new SoapClient("http://www.HOST.com/KH/TestKH/WebServices.asmx?WSDL",$options);
//var_dump($client->__getTypes());
$parameters= new stdClass();
$parameters->_hap="xxxxxxxxx";
$parameters->_hapType="TEST";
//$parameters->UserID="";
//$parameters->Password="";
$parameters->Origin="AUS";
$parameters->Destination="LHR";
$parameters->FromDate="01/01/2016";
$parameters->ToDate="27/02/2016";
$parameters->Class="X";
$parameters->Airlines="";
$parameters->Adults="1";
$parameters->Childs="0";
$parameters->Infants="0";
$parameters->isReturn=true;
$parameters->CompanyCode="xxxxx";
$parameters->sessionId="xxxxxx";
$result=$client->SearchMethod($parameters);
var_dump($result);
var_dump($client->__getLastRequest());
$status=$result->SearchMethodResult;
var_dump($status);
}
catch (Exception $e){
$e -> getMessage();
var_dump($e);
}
Our request process but don't know what is the wrong with these code because show server side error "Unknown error occured!"
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();
}
I have to create a PHP SOAP client that sends leads, but I have never worked with SOAP before, and my XML isn't that great, here is the code I have managed to write so far. . .
<?php
try {
$client = new SoapClient(null, array(
'location' => "https://wwa.website.co.za/CallmasterTes/LeadService.asmx",
'uri' => "urn:Website:Callmaster:InTuch/CreateLead",
'login' => "username",
'password' => "password"
));
$sysName = ' ';
$clientCode = ' ';
$expTimestamp = ' ';
$schedTimestamp = ' ';
$client->CreateLead("ExternalLead",
new SoapParam($sysName, "BusinessSystemName"),
new SoapParam($clientCode, "BusinessSystemClientCode"),
new SoapParam($_POST['Title'], "Title"),
new SoapParam($_POST['FirstName'], "FirstName"),
new SoapParam($_POST['Surname'], "Surname"),
new SoapParam($_POST['IdNumber'], "IdNumber"),
new SoapParam($_POST['Gender'], "Gender"),
new SoapParam($_POST['DateOfBirth'], "DateOfBirth"),
new SoapParam($_POST['Language'], "Language"),
new SoapParam($_POST['EmailAddress'], "EmailAddress"),
new SoapParam($_POST['HomeTelNumber'], "HomeTelNumber"),
new SoapParam($_POST['BusinessTelNumber'], "BusinessTelNumber"),
new SoapParam($_POST['MobileTelNumber'], "MobileTelNumber"),
new SoapParam($_POST['OtherTelNumber'], "OtherTelNumber"),
new SoapParam($_POST['PreferredTelNumberCode'], "PreferredTelNumberCode"),
new SoapParam($_POST['CampaignName'], "CampaignName"),
new SoapParam($_POST['ProductName'], "ProductName"),
new SoapParam($_POST['Comments'], "Comments"),
new SoapParam($expTimestamp, "ExpiryTimestamp"),
new SoapParam($schedTimestamp, "ScheduledTimestamp"),
);
}
catch (SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
?>
The following is a sample SOAP 1.2 request and response that I was given by the developers on the server side of things.
POST /CallmasterTest/LeadService.asmx HTTP/1.1
Host: wwa.website.co.za
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>
<CreateLead xmlns="urn:Website:Callmaster:InTuch">
<Lead>
<BusinessSystemName>string</BusinessSystemName>
<BusinessSystemClientCode>int</BusinessSystemClientCode>
<Title>Mr or Ms or Mrs or Miss...etc</Title>
<FirstName>string</FirstName>
<Surname>string</Surname>
<IdNumber>string</IdNumber>
<Gender>Male or Female</Gender>
<DateOfBirth>date</DateOfBirth>
<Language>string</Language>
<EmailAddress>string</EmailAddress>
<HomeTelNumber>string</HomeTelNumber>
<BusinessTelNumber>string</BusinessTelNumber>
<MobileTelNumber>string</MobileTelNumber>
<OtherTelNumber>string</OtherTelNumber>
<PreferredTelNumberCode>Business or Home or Mobile or Other</PreferredTelNumberCode>
<CampaignName>string</CampaignName>
<ProductName>string</ProductName>
<Comments>string</Comments>
<ExpiryTimestamp>dateTime</ExpiryTimestamp>
<ScheduledTimestamp>dateTime</ScheduledTimestamp>
</Lead>
</CreateLead>
</soap12:Body>
</soap12:Envelope>
The 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>
<CreateLeadResponse xmlns="urn:Website:Callmaster:InTuch">
<CreateLeadResult>
<Success>boolean</Success>
<StatusMessage>string</StatusMessage>
<LeadGuid>guid</LeadGuid>
<Errors>
<LeadError ErrorLevel="Information or Warning or Error">
<Message>string</Message>
<Field>string</Field>
</LeadError>
<LeadError ErrorLevel="Information or Warning or Error">
<Message>string</Message>
<Field>string</Field>
</LeadError>
</Errors>
</CreateLeadResult>
</CreateLeadResponse>
</soap12:Body>
</soap12:Envelope>
I have really tried everything, and googled into high heaven, but I just can't get it to work, I am sure that it's probably something small that I am missing, I would really appreciate the help, thanx!
I'm not sure if this is a copy/paste error or not, but all the _POSTs should be $_POSTs in your first code example.