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.
Related
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.
I never worked with SOAP XML api before.
I read a couple of similar questions on SO but I can't get it to work.
Here's a simple request:
<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>
<CheckDomainAvailability xmlns=”https://live.domainbox.net/”>
<AuthenticationParameters>
<Reseller>myreseller</Reseller>
<Username>myuser</Username>
<Password>mypassword</Password>
</AuthenticationParameters>
<CommandParameters>
<DomainName>checkadomain.co</DomainName>
<LaunchPhase>GA</LaunchPhase>
</CommandParameters>
</CheckDomainAvailability>
</soap12:Body>
</soap12:Envelope>
I've contacted them but they do not offer a PHP API.
I would like to use the SoapClient class built in PHP.
The question is:
How do I send the request and print the answer?
Looks like your WSDL is located at https://live.domainbox.net/?WSDL.
Here's an example using the native PHP SoapClient.
$client = new SoapClient('https://live.domainbox.net/?WSDL');
// populate the inputs....
$params = array(
'AuthenticationParameters' => array(
'Reseller' => '',
'Username' => '',
'Password' => ''
),
'CommandParameters' => array(
'DomainName' => '',
'LaunchPhase' => ''
)
);
$result = $client->CheckDomainAvailability($params);
print_r($result);
To get this working I needed to change the first line to get the right version of soap to 1.2.
Also a previous comment
$client = new SoapClient('https://live.domainbox.net/?WSDL', array('soap_version' => SOAP_1_2));
// populate the inputs....
$params = array(
'AuthenticationParameters' => array(
'Reseller' => '',
'Username' => '',
'Password' => ''
),
'CommandParameters' => array(
'DomainName' => '',
'LaunchPhase' => ''
)
);
$result = $client->CheckDomainAvailability($params);
print_r($result);
I'm having issues attempting to pull up tracking info using Fedex's Web Services. I am using a valid tracking number and I'm able to view the details on Fedex's site. However, I get an error 9040 "No information for the following shipments has been received by our system yet. Please try again or contact Customer Service at 1.800.Go.FedEx(R) 800.463.3339." Am I leaving something out?
My code:
<?php
$path_to_wsdl = "URL_TO_WSDL";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
$request['WebAuthenticationDetail'] = array(
'UserCredential' =>array(
'Key' => 'MY_KEY',
'Password' => 'MY_PASSWORD'
)
);
$request['ClientDetail'] = array(
'AccountNumber' => 'MY_ACCT',
'MeterNumber' => 'MY_METER'
);
$request['TransactionDetail'] = array('CustomerTransactionId' => 'ActiveShipping');
$request['Version'] = array(
'ServiceId' => 'trck',
'Major' => '5',
'Intermediate' => '0',
'Minor' => '0'
);
$request['PackageIdentifier'] = array(
'Value' => 'TRACKING#',
'Type' => 'TRACKING_NUMBER_OR_DOORTAG');
$response = $client->track($request);
var_dump($response);
?>
Got it!
Call the web services departement and they told me to remove 'beta' from the wsdl file. This appears to be a different address than what I found in responses to this problem before. On line 1507 of the wsdl file, make the following change:
From:
<s1:address location="https://wsbeta.fedex.com:443/web-services/track"/>
To
<s1:address location="https://ws.fedex.com:443/web-services/track"/>
I changed the rest of my code slightly, but that shouldn't have made the difference. To be on the safe side, here it is:
<?php
$path_to_wsdl = "PATH_TO_WSDL_FILE";
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
$trackRequest = array(
'WebAuthenticationDetail' => array(
'UserCredential' => array(
'Key' => 'MY_KEY',
'Password' => 'MY_PASSWORD'
)
),
'ClientDetail' => array(
'AccountNumber' => 'MY_ACCT_#',
'MeterNumber' => 'MY_METER_#'
),
'Version' => array(
'ServiceId' => 'trck',
'Major' => '5',
'Intermediate' => '0',
'Minor' => '0'
),
'PackageIdentifier' => array(
'Type' => 'TRACKING_NUMBER_OR_DOORTAG',
'Value' => 'THE_TRACKING_#',
),
'CustomerTrasactionId',
'IncludeDetailedScans' => 1
);
$response = $client->track($trackRequest);
var_dump($response);
?>
I'm also working on this same problem. I'm trying several things and you can see if anything works for you. Try including ShipDateRangeBegin and End elements, your test account/payer numbers or destination info. I've found here that switching to xml and ssl post requests supposedly solve the problem, but it's not an option for me. Maybe it will help you?
I have same problem when use xml-request. I solved the problem this way:
$endpointurl = "https://gatewaybeta.fedex.com:443/xml"; // remove word "beta"
$endpointurl = "https://gateway.fedex.com:443/xml";
...
$request = stream_context_create($form);
$browser = fopen($endpointurl , 'rb' , false , $request);
$response = stream_get_contents($browser);
...
I'm having a recurring issue with PHP's inbuilt SOAP client where it returns the same error response regardless of the input paramaters.
Is there an advantage to using the SOAP library built into PHP or a disadvantage to directly querying via cURL through GET?
$client = new SoapClient("http://example.com/wdsl");
$params = array(
'Username' => 'username',
'Password' => 'pass',
'EventName' => 'Test Event',
'EventDate' => '2011-06-15T13:45:30',
'Destination' => '447987654321',
'Carrier' => '1',
'PhoneType' => '13',
'Originator' => 'ukflive',
'MessageText' => 'Test',
'LogoURL' => 'http://example.com/mail.gif',
'BookingReference' => '123456',
'Tickets' => '1',
'CollectionValidFrom' => '2011-06-15T13:45:30',
'CollectionValidTo' => '2011-06-15T18:45:30',
'TemplatePath' => '',
'PostBack' => 'http://example.com/'
);
$response = $client->__soapCall("SendManagedMobileTicket", $params);
print_r($response);
SoapClient is an integrated, actively maintained part of PHP5. cURL is the quick and dirty way to send HTTP data. The smart long term decision is to stick with SoapClient and its methods.
You may also want to look into the response headers, as shown in the notes section of the __soapCall() documentation page: http://www.php.net/manual/en/soapclient.soapcall.php#102387
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.