Hi guys I am trying to do a SOAP request with php, unfortunately it always returns the Error 'Wrong Version'.
My request looks like this:
<?php
$option=array('trace'=> true, 'cache_wsdl' => WSDL_CACHE_NONE, 'soap_version' => SOAP_1_2, 'exeptions' => true,);
$soapClient=new SoapClient('http://www.SOMEURL.net/SOAPAPI/HEX_XMLIF_1_1_0-0?wsdl',$option);
$soapClient->__setLocation('http://www.SOMEURL.net/SOAPAPI/HEX_XMLIF_1_1_0-0');
try{
$parameters = array(
'Version' => '1.1.0',
'TransactionIdentifier' => 'X4711',
'TimeStamp' => '2013-10-24T16:56:10',
'Target' => 'Test',
'POS' => array (
'Source' => array(
'RequestorID' => array(
'ID' => '709900001',
'ID_Context' => '1234',
'ID_Operator' => 'BJT',
'ID_Token' => '135975505',
'ID_Key' => 'znt'),
'ISOCurrency' => 'EUR',
'ISOCountry' => 'DE'),
),
'CarPark' => array(
'Code' => 'FRA8')
);
$soapClient->CarParkInformation($parameters);
}catch(SoapFault $fault){
echo '<br/><br/> Error Message : <br/>',
$fault->getMessage();
echo '<br/><br/>';
echo 'Request : <br/><xmp>',
$soapClient->__getLastRequest();
echo '</xmp><br/> Response : <br/><xmp>',
$soapClient->__getLastResponse();}
?>
According to the documentation which came with the WSDL file, my request is just fine. The only thing I am missing is a header. The header in the documentation is empty ("")-> No idea how to add an empty header to the request.
I don't think that is the reason for the version error...?
The request which is created looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="de.znt.hexapi">
<SOAP-ENV:Body>
<ns1:GetCarParkInformationRQ>
<ns1:Version>1.1.0</ns1:Version>
<ns1:TransactionIdentifier>X4711</ns1:TransactionIdentifier>
<ns1:TimeStamp>2013-10-24T16:56:10</ns1:TimeStamp>
<ns1:Target>Test</ns1:Target>
<ns1:POS>
<ns1:Source>
<ns1:RequestorID>
<ns1:ID>709900001</ns1:ID>
<ns1:ID_Context>1234</ns1:ID_Context>
<ns1:ID_Operator>BJT</ns1:ID_Operator>
<ns1:ID_Token>135975505</ns1:ID_Token>
<ns1:ID_Key>znt</ns1:ID_Key>
</ns1:RequestorID>
<ns1:ISOCurrency>EUR</ns1:ISOCurrency>
<ns1:ISOCountry>DE</ns1:ISOCountry>
</ns1:Source>
</ns1:POS>
<ns1:CarPark>
<ns1:Code>FRA8</ns1:Code>
</ns1:CarPark>
</ns1:GetCarParkInformationRQ>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I have no idea why I am getting "Wrong Version" error, I tried with 1.1 and 1.2 and I have been testing around for a few days.
Does anyone have a clue what to do?
Problem FIXED - I have been using the wrong endpoint.
Related
So I am using Soap client in PHP and I'm trying to make a request on some WSDL. I try to have a specific output but it seems a bit far from what I try to do. Maybe I don't do this right. I'm a bit new to WSDL.
Here is the result I want:
<SOAP-ENV:Body>
<loc:sendSms>
<loc:addresses>9000000000</loc:addresses>
<loc:senderName>9000000</loc:senderName>
<loc:message>test SMS</loc:message>
</loc:sendSms>
</SOAP-ENV:Body>
This is what I try to fit my requirement, but it ends with a server error:
$MCIResp = (array) $_soapClient->__soapCall('sendSms',
'sendMessage' => array(
'addresses' => '9000000000',
'senderName' => '9000000',
'message' => 'test SMS '
)
);
And this is the error I get from this request:
"SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no
'sendmessage' property";
EDIT: Made some improvements on that by getting inspiration on some posts
Here is my code now:
$_soapClient = new SoapClient(
null,
array(
'location' => 'http://someIP/parlayxsmsgw/services/SendSmsService?wsdl',
'uri' => 'http://someIP/parlayxsmsgw/services/SendSmsService?wsdl',
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'use' => SOAP_LITERAL,
'style' => SOAP_DOCUMENT,
'stream_context' => stream_context_create(array(
'http' => array(
'header' => 'servicekey: someservicekey'
),
)),
)
);
$params = new \SoapVar("<sendSms><addresses>90000000000</addresses><senderName>90000000</senderName><message>test SMS</message></sendSms>",XSD_ANYXML);
And then I do a
$_soapClient->whatEverNameHereWillBeIgnored($params);
This is now the XML I generate:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<sendSms>
<addresses>989127184955</addresses>
<senderName>98307066</senderName>
<message>test SMS</message>
</sendSms>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But I receive this as a response:
Unexpected subelement sendSms
do the "loc:" are mandatory to solve this ? Because when I add it in the raw xml it says that
Undeclared namespace prefix "loc"
Thanks,
I strongly advise you to use a WSDL to PHP generator such as PackageGenerator, it will ease you the request construction so you won't have to wonder how to construct the request, it will be cristal clear.
I got an issue here. I am trying make a request to a Web Appi: http://www.speedex.gr/getvoutrans/getvoutrans.asmx?WSDL
And I am sending a request to insertPodData();
I am using PHP and SOAP.
I am succesfull at connecting and giving the correct credentials. However I am not able to send a Dataset (cause I do not know the right way), so i get an empty dataset.
Datasets are for .NET lang. So it is kind of tricky with the php.
I tried already to send it as an array, i still get an empty result.
Here are some coding.
PHP:
$dataset = array(
'schema' => array(
'Enter_Branch_Id' => $speedex_branch_id,
'SND_Customer_Id' => $speedex_cust_id,
'SND_Agreement_Id' => $speedex_appi_key,
'RCV_Name' => 'Test',
'RCV_Addre1' => 'Test Adress',
'RCV_Zip_Code' => '54636',
'RCV_City' => 'Thessaloniki',
'RCV_Country' => 'Greece',
'RCV_Tel1' => '*******',
'Voucher_Weight' => '0',
),
'any' => ''
);
try {
$soap = new SoapClient("http://www.speedex.gr/getvoutrans/getvoutrans.asmx?WSDL",array('trace' => true));
$oAuthResult = $soap->insertPodData(
array(
'username' => $speedex_usrn,
'password' => $speedex_psw,
'VoucherTable' => $dataset,
'_tableFlag' => 3
)
);
$resultVoucher = $oAuthResult;
print_r($resultVoucher);
echo '<br>';
echo "REQUEST:\n" . htmlentities($soap->__getLastRequest()) . "\n";
die();
}catch(SoapFault $fault) {
die('<h1>Ooooops something is broken. Refresh or contact module creator </h1><br>'.$fault);
}
This is returning this result
RESULT: stdClass Object ( [insertPodDataResult] => 1 [newVoucherTable] => stdClass Object ( [schema] => [any] => ) )
REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:insertPodData>
<ns1:username>****</ns1:username>
<ns1:password>****</ns1:password>
<ns1:VoucherTable>********************TestTest Adress54636ThessalonikiGreece********</ns1:VoucherTable>
<ns1:_tableFlag>3</ns1:_tableFlag>
</ns1:insertPodData>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you can observe the Dataset is not created and all the values are passed with out a reference.
Any ideas clues? Thanks in advance!
I have an array a couple of levels deep in my SOAP request like below. When I run my SoapRequest I get Notice (8): Array to string conversion and my XML response does not convert the Array in RTrans to XML and I have no idea why. How I am creating the SOAP request and the XML version of it can be found below.
The Request:
$r['request'] = array(
'request' => array(
'user' => 'test',
'password' => 'test',
'RTrans' => array(
'Transactions' => array(
'Criteria' => array(
'Name' => 'Thomas'
)
)
)
)
);
try{
$response = $this->apiClient->DoQuery($r);
}
catch(Exception $e){
debug($e);
}
The XML Version
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://webServices/">
<SOAP-ENV:Body>
<ns1:DoNormalEnquiry>
<request>
<username>test</usernmae>
<password>test</password>
<RTrans>Array</RTrans>
</request>
</ns1:DoNormalEnquiry>
</SOAP-ENV:Body>
I think RTrans is defined as a String. Please have a look at the wsdl file.
Maybe thats the reason you got "Array" in the xml.
To send an array to your soapservice you could convert it to json.
json_encode( array('Transactions' => array('Criteria' => array('Name' => 'Thomas')));
or define a complex datatype.
Maybe SoapVar will help you.
Hi please tell me how to get reposnse
I have a wsdl and i would like to call awebservice through it
Although using soapUI i can get the reposnse but not throgh php
I am also giving the xml request that need to be made
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header /><soapenv:Body>
<q2:OneOffDeductionRequestMsg
xmlns:q0="http://www.huawei.com/bme/accountmgr"
xmlns:q1="http://www.huaweiommon"
xmlns:q2="http://www.accountmgrmsg">
<RequestHeader>
<q1:CommandId>OneOffDeduction</q1:CommandId>
<q1:Version>1</q1:Version>
<q1:TransactionId/>
<q1:SequenceId>1</q1:SequenceId>
<q1:RequestType>Event</q1:RequestType>
<q1:SessionEntity>
<q1:Name>NET</q1:Name>
<q1:Password>084912FA9733C4A0115D</q1:Password>
<q1:RemoteAddress>10.176.122.2</q1:RemoteAddress>
</q1:SessionEntity>
<q1:SerialNo>192741328589162212</q1:SerialNo>
</RequestHeader>
<OneOffDeductionRequest>
<q0:SubscriberNo>XXXXXX73</q0:SubscriberNo>
<q0:OperationID>4059999</q0:OperationID>
<q0:AdditionalInfo>VNET</q0:AdditionalInfo>
<q0:DeductAmt>100</q0:DeductAmt>
<q0:MinMeasureId>101</q0:MinMeasureId>
</OneOffDeductionRequest>
</q2:OneOffDeductionRequestMsg>
</soapenv:Body></soapenv:Envelope>
Here is the PHP code that utilizes it:
<?php
$RequestHeader = array(
'CommandId' => 'OneOffDeduction',
'Version' => '1',
'TransactionId' => '34234',
'SequenceId' => '1',
'RequestType' => 'EVENT',
'SerialNo' => '1527013286284589162212');
$SessionEntity =array(
'Name' => 'V',
'Password' => 'v',
'RemoteAddress' =>'10.0.0.0');
$wsdl ="http://eAccountMgrService?wsdl";
$client = new SoapClient($wsdl);
$param =array('SubscriberNo'=>'54321',
'OperationID' =>'4059999',
'AdditionalInfo'=>'VAS2NET',
'DeductAmt'=>'10',
'MinMeasurId'=>'101');
var_dump($client);
$Result = $client->__call('OneoffDeduction',array(
'CommandId' => 'OneOffDeduction',
'Version' => '1',
'TransactionId' => '34234',
'SequenceId' => '1',
'RequestType' => 'ET',
'SerialNo' => '1527',
'sessionEntity' =>array(
'Name' => 'V',
'Password' => 'v',
'RemoteAddress' =>'10.0.0.0')));
var_dump($Result);
echo $client->__getLastRequest();
$Response = $client->__call('OneoffDeduction',array('SubscriberNo'=>'54321',
'OperationID' =>'4059999',
' AdditionalInfo'=>'VAET',
'DeductAmt'=>'10',
'MinMeasurId'=>'101'));
echo $client->__getLastRequest();
?>
Until your code it DRY and organized, it's not easy / possible to debug the problem.
Since you define variables that you never use, it's likely that you've become confused by which vars are actually being sent to the API - e.g. $params seems never sent in any form.
Recommend you refer to the soapClient docs to ensure that you're passing the correct list.
When i sending below request, i am getting 'Wrong Version" exception.
<OTA_HotelGetMsgRQ xmlns="http://www.opentravel.org/OTA/2003/05"
TimeStamp="2001-12-17T09:30:47.0Z" Version="4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Messages>
<Message HotelCode="123" HotelName="Test Hotel" ChainCode="321"
ReasonForRequest="Reservation Retrieval" RequestCode="Optional"
ChainName="Test Chain" MessageType="All" StartSeqNmbr="1"
EndSeqNmbr="10" />
</Messages>
</OTA_HotelGetMsgRQ>
above request is converted into zend code
$client = new zend_soap_client(null,
array(
'location' => 'http://url...',
'Uri' =>"http://www.opentravel.org/OTA/2003/05"
)
);
$request = array(
array('Messages'=>
array ('Message' =>
array (
'HotelCode' => '123',
'HotelName' => 'Test Hotel',
'ChainCode' => '321',
'ReasonForRequest' => 'Reservation Retrieval',
'RequestCode' => 'Optional',
'ChainName' => 'Test Chain',
'MessageType' => 'All',
'StartSeqNmbr' => '1',
'EndSeqNmbr' => '10'
)
)
)
);
$result = $client->OTA_HotelGetMsgRQ ($request);
Above line throws exception 'Wrong Version'. Anyone help me how to solve this
sounds like you are using the wrong version ;) - have you tried to add 'soap_version'=>'1.2' (or 1.1, depending on which version is needed) to the options of your soap_client?
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('Core_Soap_Test');
$autodiscover->setUri( sprintf($this->_WSDL_URI,0) );
$autodiscover->handle();
$this->_WSDL_URI = '"http://WWW.EXAMPLE.COM/soap/index/wsdl/%s/?wsdl'
try the code above. this helped me
I had this problem as well. The problem in my case was that I wasn't passing an expected (and thus required) parameter without throwing back a SoapFault-exception. Maybe it's useful to someone.