I have created a WCF Service with callback and using wsDualHttp Binding.
I want to connect to this service using PHP client.
In PHP , SoapClient is used to call the WCF service like below:
$wsdl = "http://pathto/file.svc?wsdl"
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->somefunction();
Please guide in getting for callback in PHP.
I am sorry, but IMO its impossible to have callback from wcf to php (for exaple, this post also say so:
http://wso2.org/forum/thread/24111).
Probably you can check for some websocket solution to receive behavior you ste looking for.
Take a look on node.js, for ecample: http://bergie.iki.fi/blog/dnode-make_php_and_node-js_talk_to_each_other/
Related
I have created php file. It contains details about to access (wsdl)xml file and function. I need to call a function with paramaters but i can't able to call a function. So, I have been given a WSDL file and I need to create a SOAP service for it in PHP. Could any one tell me what the correct way of doing it is?
Here is link of the WSDL: http://178.211.55.56/se/ws/wf_ws.php?wsdl
and
Here is my php code:
require_once 'lib/nusoap.php';
ini_set("soap.wsdl_cache_enabled", "0");
$soapclient = new nusoap_client("http://178.211.55.56/se/ws/wf_ws.php?wsdl",'wsdl');
$soapclient->setHTTPProxy("soap:address_location",8080,"usr_name","pwd");
when run above the php code return this error:
wsdl error: Getting "WSDL link" - HTTP ERROR: Couldn't open socket
connection to server "WSDL link" prior to connect(). This is often a
problem looking up the host name.
Try to use http://php.net/manual/en/class.soapclient.php
All you need is:
Create SOAP client:
$client = new SoapClient("http://178.211.55.56/se/ws/wf_ws.php?wsdl");
You can pass many options to the constructor, such as proxy, cache settings, etc.
Some examples for you:
$client = new SoapClient("some.wsdl", array('soap_version' => SOAP_1_2));
$client = new SoapClient("some.wsdl", ['login' => "some_name", 'password'=> "some_password"]);
$client = new SoapClient("some.wsdl", ['proxy_host' => "localhost", 'proxy_port' => 8080]);
If ssl certificate is wrong you can ignore it. Example is here: https://gist.github.com/akalongman/56484900eaf19b18cfbd
Call one of the service defined functions:
$result = $client->getResult(['param_name' => 'param_value']);
Pay attention that your service function may have required parameters. Usually it can be found in the result message.
I need communicate with web-service construct in .net(i think), but when i try call a method, return this error:
The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/TripointWebservicesVersionedGeneral/Ping'.
Code to connect to web-service and execute method:
$client = new SoapClient(
'...?wsdl',
array(
'trace' => 1,
'soap_version' => SOAP_1_2
)
);
//$test = $client->__soapCall('Ping',array(''));
$test = $client->Ping();
What is the reason of this error? or what i need to do to call a method?
I have already read this PHP Fatal error: "The SOAP action specified on the message, '', does not match the HTTP SOAP Action", and put in option of soap connection this "'action' => '.../Ping'" but don't help me.
i've found the reason why i can't call the method's, its because of this:
One of the problems:
The PHP returns "Caught exception: Cannot process the message because the content type ‘text/xml; charset=utf-8′ was not the expected type ‘application/soap+xml; charset=utf-8′."
The reason:
WCF is running a new version of web services than expected by the PHP.
The solution:
Change the binding type of the WCF service from binding="wsHttpBinding" to binding="basicHttpBinding".
This insures that your .NET web service would support clients and other services that conform to the WS-I standards.
url source:
http://spacebug.com/php-calling-wcf-part-1-html
Not a full answer, but I just wanted to highlight that you're probably facing this problem because you're using SoapClient to try and consume a web service that uses WS-Addressing. You should try to track down what others do in this situation:
http://www.cdatazone.org/index.php?/archives/15-WS-Addressing-for-extsoap.html
https://github.com/wso2/wsf
I received a manual to internal SOAP interface of my partner. It says:
MyPARTNER web services are provided in the form of a SOAP interface. The service is available in this URL: https://justsomeurl.com:435/soap
then some bla bla about authorization etc. and then a part about Accessible Methods:
pull()
The PULL method is used for pulling data from the database. The method
receives a unique data based parameter under an internal name
requestXML. This parameter contains data in a structured XML format.
String pull(String requestXML)
The XML contains data required to make the request, and the response
data is sent back.
then some other methods, error codes, it's not important here...
The problem is that I'm totally unexperienced in SOAP so I don't know how to use this interface via PHP. I've tried to find some examples, tutorials and I am now little bit more informed about SOAP and its functionality but still haven't found any advice about how to use interface like this...
thanx for any help
Php comes with PHP SOAP libraries, that usually are included and enabled after a common php installation.
Yuo are asked to biuld the client part of the webservice pattern. Your partner should provide you the .wsdl of the web service. The wsdl describes the avialble method, the parameters they need and what they return.
Tipically parameters and return values are array structures
This could be a skeleton for your code:
//build a client for the service
$client = new SoapClient("partner.wsdl");
//$client is now a sort of object where you can call functions
//prepare the xml parameter
$requestXML = array("parameter" => "<xml>Hello</xml>");
//call the pull function this is like
$result = $client->__soapCall("pull", $requestXML );
//print the value returned by the web service
print_r($result);
Here follows a non-wsdl example
First the location paramater is the address the SOAP request will be sent to.
The uri parameter is the target namespace of the SOAP service. This is related to xml namespaces.
A sample code for you could be:
//for URI specification you should watch your partners documentation. maybe also a fake uri (like mine) could work
//build a client for the service
$client = new SoapClient(null, array(
'location' =>
"https://justsomeurl.com:435/soap",
'uri' => "urn:WebServices",
'trace' => 1 ));
// Once built a non-wsdl web service works as a wsdl one
//$client is now a sort of object where you can call functions
//prepare the xml parameter
$requestXML = array("parameter" => "<xml>Hello</xml>");
//call the pull function this is like
$result = $client->__soapCall("pull", $requestXML );
//print the value returned by the web service
print_r($result);
Here a useful link: http://www.herongyang.com/PHP/SOAP-Use-SOAP-Extension-in-non-WSDL-Mode.html
I was trying to connect to asp.net webservice from PHP,
I dont want to use nuSOAP
I have created SOAP client using default SoapClient()
$options = array('style'=>SOAP_DOCUMENT,
'use'=>SOAP_LITERAL,
'soap_version'=>SOAP_1_1,
'exceptions'=>1,
'trace'=>1
);
$clnt = new SoapClient('webserviceURL?wsdl', $options);
$clnt ->__Call('method', array('param'=>'val'));
Now, Webservice server is not recogising my Parameter that I am passing to the webservice method.
Can Anyone help me ?
If the webservice expects document/literal wrapped calling convention then you should put method parameters inside additional array:
$clnt ->__Call('method', array(array('param'=>'val')));
Yes, I got the Answer
$params = array('param'=>'val');
$resp = $clnt->method(array('param'=>$params));
'method' is webservice method you want to call
Method mentioned by Furgas will also work
The web service I'm trying to consume has such a WSDL file: http://dgpysws.teias.gov.tr/dgpys/services/EVDServis?wsdl
I'm trying to consume "setIkiliAnlasma" service, however accessing that service requires authentication. I have my credentials and when I make a SOAP call to login service it authenticates my credentials.
And as expected, when I call "setIkiliAnlasma" service I get an Authorization error. What is the method to combine authorization supplied by login call with the main service I need to consume?
By the way the programming language I'm usign is PHP and the native SoapClient functions: http://www.php.net/manual/en/class.soapclient.php
Here is an example of using the SOAPClient in PHP with authentication - you just need to adapt it to the WSDL you are using ->
// Setting "trace" will allow us to view the request that we are making, after we have made it.
$objClient = new SoapClient("http://www.somewhere.com/wsdls/some.wsdl", array('trace' => true));
// These parameters satisfy this specific remote call.
$arrParameters_Login = array('username' => 'username', 'password' => 'password');
// Invoke the remote call "login()".
$objLogin = $objClient->login($arrParameters_Login);
// Grab session ID that this remote call will provide.
$strSessionID = $objLogin->loginReturn->sessionId;
You will then need to use the sessionid / session code that is sent to you in the login response - maybe in a header - its specific to each WSDL.
try to use this way to authenticate when calling the soap client url :
http://username:password#domain.com/