how to php soap client send request? - php

I am sending parameters to the login function with the following code, but the result is empty. Where am I making mistakes?
$url = "http://wsdl.lion-playground.com/GambleServerProxy.svc?wsdl";
$client = new SoapClient($url);
$parameters = array("AuthToken"=>"asdsads23123sddds", "Identifier"=>"asdsad22212312", "Password"=>"312312321312321321");
$results = $client->Login("LoginRequest",$parameters);
var_dump($results); // Boş dönüyor ?
Fatal error: Uncaught SoapFault exception: [Client]
SoapClient::SoapClient(): 'location' and 'uri' options are required in
nonWSDL mode in /home/mornetajans/public_html/demo2/test.php:9

Related

Posting xml to SOAP service

I'm fairly new to SOAP and PHP and I'm having some troubles, that I hope someone here on Stack Overflow can help me with.
I'm trying to use this code to post a xml file (retursvar.xml).
I'm using this code to post the file:
<?php
$url = "https://someserver/somefunction";
$options = array(
'login' => 'someusername',
'password' => 'somepassword',
'trace' => 1
);
$client = new SoapClient($url.'?wsdl', $options);
$document = file_get_contents('retursvar.xml');
$params = array('SubmitDocument' => $document);
$response = $client->__soapCall('submitDocument', $params);
but I get this error in the Apache error log:
PHP Fatal error: Uncaught SoapFault exception: [bpws:forcedTermination] business exception in /var/www/html/soaptest.php:15\nStack trace:\n#0 /var/www/html/soaptest.php(15): SoapClient->__soapCall('submitDocument', Array)\n#1 {main}\n thrown in /var/www/html/soaptest.php on line 15
If i call:
var_dump($client->__getFunctions());
immediately after:
$client = new SoapClient($url.'?wsdl', $options);
I get this output:
array(1) { [0]=> string(62) "SubmitDocumentResponse submitDocument(SubmitDocument $payload)" }
What am I doing wrong?
It says that you haven't caught an exception. Try wrapping your code inside try catch block.

PHP Soap Client: SoapFault - Internal Server Error

I want to access some web service. I use PHP SoapClient like this:
$user_key = "myKey";
$service = new SoapClient('https://myadress.xsd',array(
'trace' => 1,
'exceptions' => true,
"soap_version" => SOAP_1_2
));
$sid = $service->Zaloguj($user_key);`
After that i get Exception "SoapFault: Internal Server Error"
When i call
$service->__getFunctions()
i get list
ZalogujResponse Zaloguj(Zaloguj $parameters)
When i change parameter
"soap_version"=>SOAP_1_1
i get other error:
Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'multipart/related; type="application/xop+xm
i tried many combination like:
$params = new stdClass();
$params->key = $user_key;
$sid = $service->Zaloguj($params);
and i get same error
"SoapFault: Internal Server Error"

PHP Error SoapClient getProxy()

Getting this error while using soap service php :
Fatal error: Uncaught SoapFault exception: [Client] Function ("getProxy") is not a valid method for this service in C:\webserver\www\feeder\index.php:7 Stack trace: #0 C:\webserver\www\feeder\index.php(7): SoapClient->__call('getProxy', Array) #1 C:\webserver\www\feeder\index.php(7): SoapClient->getProxy() #2 {main} thrown in C:\webserver\www\feeder\index.php on line 7
here's my code :
<?php
$wsdl = "http://localhost:8182/fg/live.php?wsdl";
$username = "aaaaa";
$password = "123456";
$client = new SoapClient($wsdl);
$proxy = $client->getProxy();
$token = $proxy->GetToken($username, $password);
var_dump("Get Token = ".$token);
$table = $proxy->ListTable($token);
var_dump("Tabel = ".$table);
?>
There's something wrong with my code ?
Please have a look at the PHP SoapClient Doku, there is no getProxy-Method. The client itself calls the functions defined in wsdl:
$token = $client->GetToken();
$client->ListTable($token);
And make shure, that you check $token, if it's really a single variable, or if it is an object.

Send other attributes with xsi:type attribute in Soap Request PHP

I am trying to set xsi:type and some attributes in the same request tag and send a php soap request. But, I am getting the following unmarshalling error. Can someone suggest a way to overcome this issue?
Soap Exception
Fatal error: Uncaught SoapFault exception: [soap:Client] Unmarshalling Error: unexpected element (uri:"", local:"_"). Expected elements are <{}iId>,<{}pId> in C:\wamp\www...
Soap Request:
<request xsi:type="ns1:PCType" xactionid="transactionid"> <pId>pId</pId> <iId>iId</iId> </request>
Code:
$request['_']['pId'] = 'pId';
$request['_']['iId'] = 'iId';
$request['xactionId'] = 'transactionid'; // it works when i comment this line :(
$request = new SoapVar($request, SOAP_ENC_OBJECT, "ns1:PCType", "" );
$r['request'] = $request;
$this->soapEnvelope = $r;
$apiResponse = $this->soapClient->__soapCall($this->apiFunc, $this->soapEnvelope, $this->soapHeader, array());

PHP SOAP : Fatal error: Uncaught SoapFault exception: [HTTP] An Authentication object was not found in the SecurityContext

I have the following error:
"PHP SOAP : Fatal error: Uncaught SoapFault exception: [HTTP] An
Authentication object was not found in the SecurityContext"
I have tried to set up soap headers but it is not working:
$authvalues = array("username"=>"####","password"=>"EEEEE");
$header = new SoapHeader("SoapBaseNameSpace","ReqHeader", $authvalues, true);
$client->__setSoapHeaders(array($header));
Have you tried setting it in the options array?
$options = array(
"login" => 'login',
"password" => 'pass'
);
$client = new SoapClient($wsdl, $options);

Categories