3
I’m having trouble understanding the process of creating a Webservice in PHP.
I created a server who makes the following call:
<?php
require_once "lib/nusoap.php";
$soap = new soap_server;
$soap->configureWSDL('WS-WebCodeFree', 'http://localhost/ws-webcodefree/');
$soap->wsdl->schemaTargetNamespace = 'http://soapinterop.org/xsd/';
$soap->register(
'info',
array(),
array('x' => 'xsd:string'),
'http://soapinterop.org/'
);
$soap->service(isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '');
function info(){
return "WebCodeFree - Desenvolvimento Web.";
}
On the client side:
<?php
include "lib/nusoap.php";
$client = new SoapClient('http://localhost/web-service/ws-webcodefree.php?wsdl');
$result1 = $client->call('info');
It returns me the error:
Fatal error: Uncaught Soapfault Exception: [Client] Function ("call") is not a Valid method for this service in C: Github Voxy app return index.php:3 Stack trace: #0 C: Github Voxy app retorno index.php(3): Soapclient->__call('call', Array) #1 C: Github Voxy app return index.php(3): Soapclient->call('info') #2 {main} thrown in C: Github Voxy app return index.php on line 3
There seems to be a conflict between Nusoap and SOAP, from what I read.
If I change the calls, to nusoap_client
in the customer’s call, resolve.
But I wanted to know for a fact, where is the problem, and what is the difference between them?
you would have some example in native SOAP, in PHP ?
– Brunno Sena
@Brunnosena I already made the edition with an example referring to yours with the library ... !!! take a look at!
– novic
Okay, I just saw it. Another question. If I do Webservice with Nusoap. Can I communicate from other languages, just with the URL? If I want to put at the disposal of some partner, to consume this Webservice, will they get ? Or only with native SOAP? What you would recommend to me ?
– Brunno Sena
yes. @Brunnosena, the one in your question does not generate WSDL the correct is always generate, I did according to the question, but, yes it is by the address that is consumed!
– novic
Okay, @Virgilio-novic saw it now. Another question. In case I do Webservice with Nusoap. Can I communicate from other languages, only with the URL? If I want to make it available to some partner, to consume this Webservice, will they get ? Or only with native SOAP? What would you recommend ?
– Brunno Sena
Yes this is the main idea of existing Webservice that other languages and clients consume, but nowadays are using what has a better performance that is the
json
the famous Webapi.– novic