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
Related
I'm working with a SOAP API, and they've disabled the WSDL document that's normally located in the base .asmx URL for SOAP APIs. The page is instead a 404 page when viewed without an XML request. Right now, simply instantiating a SoapClient fails ($soap = new SoapClient($url);, the error is Premature end of data in tag html line 1). I'm assuming here that a new instance of SoapClient tries to retrieve the WSDL from the server. Is there a way of turning this off? Of saying 'I want to use SoapClient, but don't do any calls until I tell you the XML call that you'll be using (along with all required data)'?
EDIT: I've tried setting cache_wsdl to WSDL_CACHE_NONE but I still get that error.
You have to run SoapClient in non-wsdl mode therefore you must set the wsdl parameter of the SoapClient c'tor to null
public SoapClient::SoapClient ( mixed $wsdl [, array $options ] )
Initialize it the following way
$client = new SoapClient(null, array('location' => http://your_domain/your_webservice",
'uri' => "http://namespace_of_the_webservice/"));
location...The location of the webservice
uri...The namespace of the target webservice
I have a wcf service and I can access that using soapclient in php, Now I am going to use load balancer and this article is saying 'set false to keepAliveEnabled'. Therefore I used customeBindings. but the issue is now I can not access the service using php. I saw many articles saying use basicHttpBindings, but I can not use that method. I am getting this error.
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-16LE'.
Therefore I added soapversion to SoapClient
$client = new SoapClient($wsdl, array('uri' => 'http://tempuri.org/','soap_version' => SOAP_1_2,'trace' => true,'cache_wsdl' => WSDL_CACHE_NONE,'keep_alive' => false));
then I am getting this error.
Caught exception: The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://Microsoft.ServiceModel.Samples/Service1'
This is the customBinding I used.
<customBinding>
<binding name="HttpBinding" keepAliveEnabled="False"/>
</customBinding>
Can anyone tell me how to resolve this. Or any other way to do this. Thanks
I am trying to make a webservice controller for a Zend framework in PHP. I'm using non-WSDL mode (though I suppose if it comes down to it, I can build a WSDL file).
class WebserviceController extends Zend_Controller_Action
{
public function soapAction()
{
$this->getHelper('viewRenderer')->setNoRender(true);
$soap_options = array('uri'=>$_SERVER['DOCUMENT_ROOT'] . 'webservice/soap/');
echo $soap_options;
$server = new Zend_Soap_Server( null, $soap_options );
$server->setClass('WebserviceAPI');
$server->handle();
}
}
WebserviceAPI is a plain-old object:
class WebserviceAPI
{
public function returnblah($one, $two)
{
return $one . ", " . $two . ": blah!";
}
}
I'm attempting to test this just to see if I can make it connect:
$options = array('login' => '***',
'password' => '********',
'location' => 'https://localhost:8888/webservice/soap',
'uri' => 'https://localhost:8888/',
'trace' => 1);
$soap = new SoapClient(null, $options);
echo $soap->returnblah("a-one", "a-two");
It's not connecting. Fact is, I'm not sure what the correct location and uri for a Zend SOAP server should be, when it's built in non-WSDL mode. The documentation isn't clear on how to connect to a Zend SOAP server built this way.
ETA: I've included login and password in case authentication is the reason it's not connecting (though I suspect it's not even getting that far).
ETA2: Here's the actual error message:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /Users/sabrina/Documents/testws2.php:28
where line 28 is the actual call to $soap->returnblah(). (My code posted here omits a lot of crap I've commented out in trying to solve this.)
I'm beginning to suspect my actual connection problem may be that the SOAP client is trying to send an https request over http, so I'm trying to work that out, but it would still be helpful to know if I am using the right location and uri parameters.
Thanks in advance!
According to the Zend documentation for Zend_Soap_Server and the SoapClient documentation, the 'uri' option specifies the SOAP uri namespace in both cases.
Make sure that both 'uri' options are set to the same value in your server and client, which is not the case in your example.
The 'location' option in SoapClient should be set to the URL on which your php application is configured in your web server.
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/
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