Hello i am very new to webservice, in php with below code i am trying to make soap request as shown in below XML, but it says
Error
HTTP Error: Unsupported HTTP response status 405 Method Not Allowed (soapclient->response has contents of the response)
Q.
1)how to pass headers
2)how to pass FetchCalendarRequest
i have used nusoap here but if u have soap php class solution is also invited.
<?php
error_reporting(E_ALL);
require("../lib/nusoap.php");
error_reporting(E_ALL ^ E_NOTICE);
$ERROR_MSG = '';
$s_WSPROTOCOL = 'http';
$s_WSHOSTNAME = '###.###.###.##';
$s_WSPORT = ':8080';
$s_WSPATHNAME = 'ows_ws_51/Availability.asmx?WSDL';
$s_WSTIPOOP = 'FetchCalendar';
$parameters['StayDateRange'] = array('StartDate' => '2013-10-01','EndDate' => '2013-10-10');
echo $s_WSTIPOOP."<br />";
echo $s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME."<br /><br /><br />";
$client = new nusoap_client($s_WSPROTOCOL."://".$s_WSHOSTNAME.$s_WSPORT."/".$s_WSPATHNAME, true);
$result = $client->call($s_WSTIPOOP, $parameters);
if ($client->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
}
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
?>
XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<OGHeader transactionID="005435" timeStamp="2008-12-09T13:26:56.4056250-05:00" xmlns="http://webservices.test.com/og/4.3/Core/">
<Origin entityID="OWS" systemType="WEB" />
<Destination entityID="WEST" systemType="ORS" />
</OGHeader>
</soap:Header>
<soap:Body>
<FetchCalendarRequest xmlns:a="http://webservices.test.com/og/4.3/Availability/" xmlns:hc="http://webservices.test.com/og/4.3/HotelCommon/" xmlns="http://webservices.test.com/ows/5.1/Availability.wsdl">
<HotelReference chainCode="AXA" hotelCode="AXAMUM" />
<StayDateRange>
<hc:StartDate>2013-10-01</hc:StartDate>
<hc:EndDate>2013-10-10</hc:EndDate>
</StayDateRange>
<GuestCount>
<hc:GuestCount ageQualifyingCode="ADULT" count="1" />
<hc:GuestCount ageQualifyingCode="CHILD" count="0" />
</GuestCount>
</FetchCalendarRequest>
</soap:Body>
</soap:Envelope>
Post Url :http://000.000.000.00:8080/ows_ws_51/Availability.asmx
Soap Action : http://webservices.test.com/ows/5.1/Availability.wsdl#FetchCalendar
It seems you don't have to send credentials, this returns a answere:
<?php
$soap = new SoapClient('http://webservices.micros.com/ows/5.1/Availability.wsdl', array("trace" => 1, "exception" => 0));
var_dump($soap->FetchCalendar(array(
'StayDateRange' => array(
'StartDate' => '2013-10-01',
'EndDate' => '2013-10-10'
)
)));
It still needs a HotelReference tough.
===
Here is how to set SoapHeaders:
<?php
$headerbody = array('Origin' => 'foo',
'Destination' => 'bar');
$header = new SOAPHeader($ns, 'RequestorCredentials', $headerbody);
$soap->__setSoapHeaders($header);
More on the subject can be found: http://php.net/manual/en/soapclient.setsoapheaders.php
===
Here is the soapui response when you want to perform that method
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:core="http://webservices.micros.com/og/4.3/Core/" xmlns:ava="http://webservices.micros.com/ows/5.1/Availability.wsdl" xmlns:hot="http://webservices.micros.com/og/4.3/HotelCommon/">
<soapenv:Header>
<core:OGHeader transactionID="?" authToken="?" timeStamp="?" primaryLangID="E" channelValidation="true" terminalID="?">
<core:Origin entityID="?" organizationID="?" systemType="?"/>
<core:Destination entityID="?" organizationID="?" systemType="?"/>
<!--Optional:-->
<core:Intermediaries>
<!--1 or more repetitions:-->
<core:EndPoint entityID="?" organizationID="?" systemType="?"/>
</core:Intermediaries>
<!--Optional:-->
<core:Authentication>
<core:UserCredentials>
<core:UserName>?</core:UserName>
<core:UserPassword>?</core:UserPassword>
<core:Domain>?</core:Domain>
<!--Optional:-->
<core:SecurityId>?</core:SecurityId>
</core:UserCredentials>
<!--Optional:-->
<core:Licence>
<!--Optional:-->
<core:Key>?</core:Key>
</core:Licence>
</core:Authentication>
</core:OGHeader>
</soapenv:Header>
<soapenv:Body>
<ava:FetchCalendarRequest>
<ava:HotelReference chainCode="?" hotelCode="?">?</ava:HotelReference>
<ava:StayDateRange>
<hot:StartDate>?</hot:StartDate>
<!--You have a CHOICE of the next 2 items at this level-->
<hot:EndDate>?</hot:EndDate>
<hot:Duration>?</hot:Duration>
</ava:StayDateRange>
<!--Optional:-->
<ava:GuestCount isPerRoom="?">
<!--1 or more repetitions:-->
<hot:GuestCount ageQualifyingCode="?" otherAgeQualifyingCode="?" age="?" count="?"/>
</ava:GuestCount>
<!--Optional:-->
<ava:RatePlanCode>?</ava:RatePlanCode>
<!--Optional:-->
<ava:RoomTypeCode>?</ava:RoomTypeCode>
<!--Optional:-->
<ava:BlockCode>?</ava:BlockCode>
<!--Optional:-->
<ava:CorporateCode>?</ava:CorporateCode>
<!--Optional:-->
<ava:PromotionCode>?</ava:PromotionCode>
<!--Optional:-->
<ava:NumberOfNights>?</ava:NumberOfNights>
<!--Optional:-->
<ava:RestrictedMode>?</ava:RestrictedMode>
<!--Optional:-->
<ava:InventoryMode>?</ava:InventoryMode>
</ava:FetchCalendarRequest>
</soapenv:Body>
</soapenv:Envelope>
If i compare it to your settings, the options you send with the response you do not provide the UserCredentials. And that gives me the feeling you get the error that you are not allowed to use that method. Start with providing your credentials.
Related
I am Trying to get the same data which I got using SOAPUI in PHP as I can't export in PHP.
See My WSDL file. The function I am calling is AUXTableAdminstration.
If I am fetching the whole table the PHP code works but if I use anything between <web:xDoc> </web:xDoc> then I am having trouble.
Input SOAP Request in SOAPUI
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webcominc.com/">
<soapenv:Header/>
<soapenv:Body>
<web:AUXTableAdministration>
<!--Optional:-->
<web:userName>UserName</web:userName>
<!--Optional:-->
<web:password>Password</web:password>
<!--Optional:-->
<web:action>EXPORTROWS</web:action>
<!--Optional:-->
<web:tableName>ContactData</web:tableName>
<web:xDoc>
<Root>
<Columns>
<Column>ContactInternalId</Column>
<Column>ContactName</Column>
</Columns>
<SearchCriteria>
<Value>12345</Value>
<Value>TestName</Value>
</SearchCriteria >
</Root>
</web:xDoc>
</web:AUXTableAdministration>
</soapenv:Body>
</soapenv:Envelope>
I am searching the row values using the above Request
OUTPUT for SOAPUI
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AUXTableAdministrationResponse xmlns="http://webcominc.com/">
<AUXTableAdministrationResult>
<Result>
<Status>OK</Status>
<Message>action 'EXPORT' for ContactData succeeded</Message>
<Root>
<Columns>
<Column>CpqTableEntryId</Column>
<Column>ContactInternalId</Column>
<Column>ContactName</Column>
<Column>CustomerInternalId</Column>
<Column>Company</Column>
</Columns>
<Rows>
<Row>
<Value>1234</Value>
<Value>1234</Value>
<Value>Test Value</Value>
<Value>86392</Value>
<Value>Erin Test2</Value>
</Row>
</Rows>
</Root>
</Result>
</AUXTableAdministrationResult>
</AUXTableAdministrationResponse>
</soap:Body>
</soap:Envelope>
PHP file I am using with WSDL:
<?php
header('Content-Type: application/xml; charset=utf-8');
ini_set('soap.wsdl_cache_enable', '0');
$username ="username";
$password = "password";
$action = "EXPORTROWS";
$tablename= "ContactData";
$xml ="<Root><Columns><Column>ContactInternalId</Column><Column>ContactName</Column></Columns><SearchCriteria><Value>86393</Value><Value>Erin Hensz</Value></SearchCriteria></Root>";
$parameters= array('userName' => $username,'password' => $password,'action' => $action,'tableName' => $tablename,xDoc => $xml);
$options = array('soap_version'=>SOAP_1_1,'exceptions'=>true,'trace'=>1,'cache_wsdl'=>WSDL_CACHE_NONE);
$client = new SoapClient('https://sandbox.webcomcpq.com/wsAPI/wssrv.asmx?WSDL' , $options);
$data = $client->AUXTableAdministration($parameters);
echo $result= $client->__getLastResponse();
?>
PHP OUTPUT
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AUXTableAdministrationResponse xmlns="http://webcominc.com/">
<AUXTableAdministrationResult>
<Result xmlns="http://webcominc.com/">
<Status>NOK</Status>
<Message>EXPORTROWS failed</Message>
<Error>
<ErrorCode>100000</ErrorCode>
<Description>
Object reference not set to an instance of an object.
</Description>
</Error>
</Result>
</AUXTableAdministrationResult>
</AUXTableAdministrationResponse>
</soap:Body>
</soap:Envelope>
I have to make a SOAP Call on a Axis2 Server with parameters, but I have a lot of problems, I done this on SOAPUI and works fine.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<Seguridad>
<usuario>0000000000</usuario>
<password>9FDB5D2R4J62755C7DA205S52D8G4H36D4CRCB94978BC40DDD2D4220CB63FE7E</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>
</soapenv:Header>
<soapenv:Body>
<ws:enviaCONVOL xmlns:ws="http://ws.convol/">
<!--Optional:-->
<arg0>2014-12-31</arg0>
<!--Optional:-->
<arg1>11:48:46</arg1>
<!--Optional:-->
<arg2>ZmUxMzc3ZDmyYTc3YTAyZjM2YT8lZDc4MzgwOTZhY2Y0YTM1MDg3Wg==</arg2>
<!--Optional:-->
<arg3>ZmUxMzc3ZDmyYTc3YTAyZjM2YT8lZDc4MzgwOTZhY2Y0YTM1MDg3Wg==</arg3>
</ws:enviaCONVOL>
</soapenv:Body>
</soapenv:Envelope>
I need do this with soap in PHP and MTOM, and the arg2 is a CID from a zip file.
When I tried to implement the header and send the SOAP call to the server always receive "Internal Error " or "Unknown Content-Encoding". I am having some problems with the headers and the correct implementation of the call, I need to send like the code.
what i get with PHP:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.convol/"><SOAP-ENV:Body><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<Seguridad>
<usuario>0000105847</usuario>
<password>9FDBDE265822755C7DA2058053B61580736ECB94978BC40DDD2D4220CB63FE7E</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>
</soapenv:Header>
<soapenv:Body>
<ws:enviaCONVOL xmlns:ws="http://ws.convol/">
<!--Optional:-->
<arg0>2014-12-31</arg0>
<!--Optional:-->
<arg1>11:48:46</arg1>
<!--Optional:-->
<arg2>ZmUxMzc3ZDQyYTc3YTAyZjM2YThlZDc4MzgwOTZhY2Y0YTM1MDg3Ng==</arg2>
<!--Optional:-->
<arg3>ZmUxMzc3ZDQyYTc3YTAyZjM2YThlZDc4MzgwOTZhY2Y0YTM1MDg3Ng==</arg3>
</ws:enviaCONVOL>
</soapenv:Body>
</soapenv:Envelope></SOAP-ENV:Body></SOAP-ENV:Envelope>
I had this on PHP
try{
$client=new SoapClient('https://www.convolmiscelaneapruebas.pemex.com/ServiciosCVWEB/ServicioEnviaCONVOLService/ServicioEnviaCONVOLService.wsdl',array( 'trace' => 1, 'exceptions' => 0 ));
$header = '<SOAP-ENV:Header>
<Seguridad>
<usuario>0000000000</usuario>
<password>9FDBDE265822755C50dHD5D33B61580736ECB94978BC40DDD2D4220CB63FE7E</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>
</SOAP-ENV:Header>';
$xml = '<ns1:enviaCONVOL>
<!--Optional:-->
<arg0>2014-12-31</arg0>
<!--Optional:-->
<arg1>11:48:46</arg1>
<!--Optional:-->
<arg2>ZmUxMzc3ZDQyYTc3YTAyZddd5IMKYThlZDc4MzgwOTZhY2Y0YTM1MDg3Ng==</arg2>
<!--Optional:-->
<arg3>ZmUxMzc3ZDQyYTdnHD90D3185D4MzgwOTZhY2Y0YTM1MDg3Ng==</arg3>
</ns1:enviaCONVOL>
';
$args = array(new SoapVar($xml, XSD_ANYXML));
$res = $client->__soapCall('enviaCONVOL', $args);
echo "<hr>Last Request<br>";
echo "<pre>", htmlspecialchars($client->__getLastRequest()), "</pre>";
print_r($res);
}catch (SoapFault $fault){
echo "SOAPFault: ".$fault->faultcode." - ".$fault->faultstring.' - '.$fault->getMessage();
}
I canĀ“t put the Header in the right place...
I used NuSoap
$wsdl = "https://www.convolmiscelaneapruebas.pemex.com/ServiciosCVWEB/ServicioEnviaCONVOLService/ServicioEnviaCONVOLService.wsdl";
$client = new nusoap_client($wsdl,TRUE);
$header =
"<Seguridad>
<usuario>0000000000</usuario>
<password>4e671bf08913d677c56359262117c8e67a5507b165f727288a487040bf2a1780</password>
<fechaSistema>02/01/2015</fechaSistema>
</Seguridad>";
$operation = array('arg0' => '2014-12-31',
'arg1' => '11:48:46',
'arg2'=>'12095866ae89b7dbcd44640189c57e185918192739040eb52ba5b==',
'arg3'=>'ZmU5866axMzc3ZDQyJmdAyZjM2YThlZDb7dbcd446401YTM1Mg3Ng=='
);
$client->setHeaders($header);
$res = $client->call('enviaCONVOL',$operation);
<?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>
<SubmitRequest xmlns="http://tripauthority.com/hotel">
<siteID>string</siteID>
<username>string</username>
<password>string</password>
<xmlFormattedString>string</xmlFormattedString>
</SubmitRequest>
</soap:Body>
</soap:Envelope>
we have to call above soap xml. i have siteID, username, password.
where string is below
<ArnRequest><Availability DisplayCurrency="USD" SearchTimeout="15"><HotelAvailability InDate="2007-04-26" OutDate="2007-04-29" Rooms="1" Adults="2" Children="0"><Hotel HotelID="8800"/></HotelAvailability></Availability></ArnRequest>
i have no idea on soap request. Please help with this to get response on above soap xml in PHP. The above xml is of ARN(Alliance reservations)
thanks in advance.
Calling webservices is quite easy, if you just want to send a prepared raw xml request. You could for instance use CURL for this.
Here the code which uses the php soapclient. I get "invalid credentials", but this should be ok as you'd put your valid ones in there.
<?
$string ='<ArnRequest><Availability DisplayCurrency="USD" SearchTimeout="15"><HotelAvailability InDate="2007-04-26" OutDate="2007-04-29" Rooms="1" Adults="2" Children="0"><Hotel HotelID="8800"/></HotelAvailability></Availability></ArnRequest>';
$xmlrequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hot="http://tripauthority.com/hotel">
<soapenv:Header/>
<soapenv:Body>
<hot:SubmitRequestDoc>
<!--Optional:-->
<hot:siteID>string</hot:siteID>
<!--Optional:-->
<hot:aUserName>string</hot:aUserName>
<!--Optional:-->
<hot:aPassword>string</hot:aPassword>
<!--Optional:-->
<hot:aRequestDoc>
'.$string.'
</hot:aRequestDoc>
</hot:SubmitRequestDoc>
</soapenv:Body>
</soapenv:Envelope>';
//Change this variables.
$location_URL = 'http://tripauthority.com/hotel.asmx';
$action_URL = "http://tripauthority.com/hotel/SubmitRequestDoc";
$client = new SoapClient(null, array(
'location' => $location_URL,
'uri' => "http://tripauthority.com/hotel",
'trace' => 1,
));
$order_return = $client->__doRequest($xmlrequest,$location_URL,$action_URL,1);
//Get response from here
print_r($order_return);
?>
I have solve my question if any body in future have any problem they this code works for him, please check-
<?php
error_reporting(E_ALL);
define('API_SITEID', $your_siteid);
define('API_USERNAME', $your_uname);
define('API_PASSWORD', $your_pass);
define('API_WSDL', 'http://tripauthority.com/hotel.asmx?WSDL');
ini_set("soap.wsdl_cache_enabled", "0");
$xmlReq = '<ArnRequest>
<Availability DisplayCurrency="USD" SearchTimeout="15">
<HotelAvailability InDate="2014-09-26" OutDate="2014-09-27" Rooms="1" Adults="1" Children="0">
<Hotel HotelID="8800"/>
</HotelAvailability>
</Availability>
</ArnRequest>';
echo '<form action="" method="post">
<strong>XML Request:</strong>
<p>
<textarea style="width:100%;height:400px;" id="xmlReq" name="xmlReq">'.$xmlReq.'</textarea>
</p>
<input type="submit" name="submit" id="submit" value="Test Request">
<input type="hidden" name="avail" id="avail" value="y">
</form>';
if($_POST['avail'] == "y") {
$xmlRes = doSoapRequest((($_POST['xmlReq']) ? $_POST['xmlReq'] : $xmlReq));
echo '<strong>XML Response:</strong>
<p>
<textarea style="width:100%;height:400px;" id="xmlRes" name="xmlRes">'.$xmlRes.'</textarea>
</p>';
}
function doSoapRequest($xmlReq) {
try {
$client = new SoapClient(API_WSDL);
return $client->SubmitRequestRpc(API_SITEID, API_USERNAME, API_PASSWORD, $xmlReq);
} catch(SoapFault $exception) {
return "Fault Code: {$exception->getMessage()}";
}
}
?>
Thanks
php has a built in Soap Client as of 5: http://php.net/manual/en/class.soapclient.php
$wsdl = '
<?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>
<SubmitRequest xmlns="http://tripauthority.com/hotel">
<siteID>string</siteID>
<username>string</username>
<password>string</password>
<xmlFormattedString>string</xmlFormattedString>
</SubmitRequest>
</soap:Body>
</soap:Envelope>
';
try {
$client = #new SOAPClient($wsdl); // or preferably, use a url for $wsdl
// Be sure to replace soapMethodToUse with a mouthed for this specific web service.
$response = $client->soapMethodToUse(array('key' => 'val')); // Any params for this method
} catch (Exception $e) {
echo $e->getMessage();
}
die(var_dump($response));
You may try to modify request with help of __doRequest function.
<?php
require_once("MySoapClient.php");
$client = new MySoapClient($wsdUrl,array(
'location' => "http://tripauthority.com/hotel",
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE
)
);
$parameters=array('siteID'=>'string','username'=>'string','password'=>'string');
$err=0;
try{
$info = $client->__soapCall("SubmitRequest",array($parameters));
}
catch (SoapFault $e) {
echo "<pre>faultcode: '".$e->faultcode."'</pre>";
echo "<pre>faultstring: '".$e->getMessage()."'</pre>";
$err=1;
}
if($err==0)
print_r($info);
else
echo $client->__getLastRequest();
?>
MySoapClient.php
<?php
class MySoapClient extends SoapClient
{
function __doRequest($request, $location, $action, $version, $one_way = 0) {
$request=str_replace('</SubmitRequest>','<xmlFormattedString>string</xmlFormattedString></SubmitRequest>',$request);
return $request;
}
}
?>
I would like to send the following XML request to a WSDL web service :
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-'.$nonce.'">
<wsse:Username>xxxxx</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxxx</wsse:Password>
</wsse:UsernameToken>
<wsu:Timestamp wsu:Id="Timestamp-'.$nonce.'" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>'.$timestamp.'</wsu:Created>
<wsu:Expires>'.$expiration.'</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<prep:requestListeSeancesCtrlAcces>
<codeManifestation>xxxx</codeManifestation>
<!--Optional:-->
<debutIntervalle/>
<!--Optional:-->
<finIntervalle/>
</prep:requestListeSeancesCtrlAcces>
</soapenv:Body>
</soap:Envelope>
How can I do this? I tried PHP soap extension and also NuSOAP with no success :(
Thanks for your help.
Have you tried HttpRequest::send ? E.g. see the example at http://www.php.net/manual/en/function.httprequest-send.php#95734 and fill in your own data:
<?php
//set up variables
$theData = '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-'.$nonce.'">
<wsse:Username>xxxxx</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxxx</wsse:Password>
</wsse:UsernameToken>
<wsu:Timestamp wsu:Id="Timestamp-'.$nonce.'" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>'.$timestamp.'</wsu:Created>
<wsu:Expires>'.$expiration.'</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<prep:requestListeSeancesCtrlAcces>
<codeManifestation>xxxx</codeManifestation>
<!--Optional:-->
<debutIntervalle/>
<!--Optional:-->
<finIntervalle/>
</prep:requestListeSeancesCtrlAcces>
</soapenv:Body>
</soap:Envelope>';
$url = 'http://www.example.com';
$options = array();
//create the httprequest object
$httpRequest_OBJ = new httpRequest($url, HTTP_METH_POST, $options);
//add the content type
$httpRequest_OBJ->setContentType = 'Content-Type: text/xml';
//add the raw post data
$httpRequest_OBJ->setRawPostData ($theData);
//send the http request
$result = $httpRequest_OBJ->send();
//print out the result
echo "<pre>"; print_r($result); echo "</pre>";
?>
when i consume wsdl i use cURL
for modifying headers and Envelopes use this:
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soapenvelope);
I am trying to generate a SOAP XML request that looks something like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dto="dto" xmlns:com="">
<soapenv:Header>
<dto:AuthenticationDTO>
<dto:LOGIN_ID>login</dto:LOGIN_ID>
<dto:LOGIN_PASSWORD>login</dto:LOGIN_PASSWORD>
</dto:AuthenticationDTO>
</soapenv:Header>
<soapenv:Body>
<com:createAccount>
<com:AccountFields>
<!--Zero or more repetitions:-->
<dto:FieldDTO>
<!--Optional:-->
<dto:children/>
<!--Optional:-->
<dto:fieldType>GENERAL</dto:fieldType>
<!--Optional:-->
<dto:index>0</dto:index>
<!--Optional:-->
<dto:label>BusinessName</dto:label>
<!--Optional:-->
<dto:name>BizInfo-BusinessName</dto:name>
<!--Optional:-->
<dto:value>the business name</dto:value>
</dto:FieldDTO>
<!--Zero or more repetitions:-->
<dto:FieldDTO>
<!--Optional:-->
<dto:children/>
<!--Optional:-->
<dto:fieldType>GENERAL</dto:fieldType>
<!--Optional:-->
<dto:index>0</dto:index>
<!--Optional:-->
<dto:label>BusinessCountry</dto:label>
<!--Optional:-->
<dto:name>BizInfo-Country</dto:name>
<!--Optional:-->
<dto:value>US</dto:value>
</dto:FieldDTO>
</com:AccountFields>
<com:ApplicationNumber></com:ApplicationNumber>
<com:CreditTerms></com:CreditTerms>
<com:GenerateAccountIdIndicator>true</com:GenerateAccountIdIndicator>
</com:createAccount>
I get a response using this code:
$matchCompany->FieldList->FieldDTO->fieldType = 'GENERAL';
$matchCompany->FieldList->FieldDTO->label = 'Business Name';
$matchCompany->FieldList->FieldDTO->name = 'BizInfo-BusinessName';
$matchCompany->FieldList->FieldDTO->index = '0';
try
{
$result = $soapClient->getAccountInfo($matchCompany);
print "<pre>";
print_r($result);
print "</pre>";
echo "REQUEST:\n" . htmlentities($soapClient->__getLastRequest()) . "\n";
}
catch(SoapFault $fault)
{
echo $fault->faultcode . "-" . $fault->faultstring;
echo "REQUEST:\n" . htmlentities($soapClient->__getLastRequest()) . "\n";
}
but if I try to array the fielddto item like this:
//$matchCompany->FieldList->FieldDTO[]['fieldType'] = 'GENERAL';
//$matchCompany->FieldList->FieldDTO[]['label'] = 'Business Name';
//$matchCompany->FieldList->FieldDTO[]['name'] = 'BizInfo-BusinessName';
//$matchCompany->FieldList->FieldDTO[]['index'] = '0';
It wraps each item in it's own FieldDTO tag instead of placing all four items in a single FieldDTO tag.
What am I missing? It seems like it should work, but it's not quite right.
Note that every time you execute $matchCompany->FieldList->FieldDTO[]['any_field'] the index of the array is increased by one. You could use a defined and manually incremented index (e.g. $matchCompany->FieldList->FieldDTO[$i]['any_field'] = 'any_value') or simply set all the values at once:
$matchCompany->FieldList->FieldDTO[] = array(
'fieldType' => 'GENERAL',
'label' => 'Business Name',
'name' => 'BizInfo-BusinessName',
'index' => '0'
);