Hi community,
I have a problem with a Soap client written in php.
I have a local server (coded in c and a client in c too, it works fine), but i want to test client in php, and i have an error (I'm not sure to understand it...) :
And when I run the server, I have this:
My wsdl file seems well:
So I think my problem is in client.php, but, i don't find it:
A test with nc show me some informations are received, but...
If you have any ideas, suggestions, I'll take it
Thanks in advance
--regards
Greg
I have a problem with a Soap client written in php.
I have a local server (coded in c and a client in c too, it works fine), but i want to test client in php, and i have an error (I'm not sure to understand it...) :
Code:
SoapFault exception: [SOAP-ENV:Client] Method 'ns1:getMetadataRequest' not implemented: method name or namespace not recognized in beta_2/soap.php:26
Stack trace:
#0 /root/src/rxtxws/beta_2/soap.php(26): SoapClient->__soapCall('getMetadata', Array)
#1 {main}
Code:
Socket connection successful: master socket = 3 SOAP 1.1 fault: SOAP-ENV:Client [no subcode] "Method 'ns1:getMetadataRequest' not implemented: method name or namespace not recognized" Detail: [no detail]
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- partie 1 : Definitions -->
<wsdl:definitions
targetNamespace="http://192.168.0.16:8080"
xmlns:typens="http://192.168.0.16:8080"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<!-- partie 2 : Types-->
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://192.168.0.16:8080">
<xsd:element name="getMetadataRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="oldname" type="xsd:string" />
<xsd:element name="newname" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getMetadataResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="answer" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<!-- partie 3 : Message -->
<wsdl:message name="getMetadataRequestMessage">
<wsdl:part name="input" element="typens:getMetadataRequest"/>
</wsdl:message>
<wsdl:message name="getMetadataResponseMessage">
<wsdl:part name="output" element="typens:getMetadataResponse"/>
</wsdl:message>
<!-- partie 4 : Port Type -->
<wsdl:portType name="WebServicesPortType">
<!-- partie 5 : Operation -->
<wsdl:operation name="getMetadata">
<wsdl:input message="typens:getMetadataRequestMessage"/>
<wsdl:output message="typens:getMetadataResponseMessage"/>
</wsdl:operation>
</wsdl:portType>
<!-- partie 6 : Binding -->
<binding name="WebServicesBinding" type="typens:WebServicesPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getMetadata">
<soap:operation soapAction="getMetadata"/>
<wsdl:input><soap:body use="literal"/></wsdl:input>
<wsdl:output><soap:body use="literal"/></wsdl:output>
</wsdl:operation>
</binding>
<!-- partie 7 : Service -->
<wsdl:service name="WebServices">
<!-- partie 8 : Port -->
<wsdl:port name="WebServicesPort" binding="typens:WebServicesBinding">
<soap:address location="http://192.168.0.16:8080"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Code:
<?php
require_once 'SOAP/Client.php';
ini_set("soap.wsdl_cache_enabled", FALSE);
$wsdl_file = 'file.wsdl';
class getMetadataRequest
{
public $oldname;
public $newname;
public function __construct( $oldname, $newname )
{
$this->oldname = $oldname;
$this->newname = $newname;
}
}
try {
$classmap = array('getMetadataRequest' => 'oldname', 'getMetadataRequest' => 'newname');
$soapClient = new SoapClient($wsdl_file, array('classmap' => $classmap, 'exception' => true, 'trace' => true));
$oldname = "oldname";
$newname = "newname";
$getMetadataRequest = new getMetadataRequest($oldname, $newname );
$getMetadataResponse = $soapClient->__soapCall(getMetadata, array($getMetadataRequest));
/* $getMetadataResponse = $soapClient->getMetadata($getMetadataRequest); */
$result = $getMetadataResponse->answer;
echo $result;
}
catch (SoapFault $fault)
{
echo $fault."\n";
}
?>
Code:
$nc -l -p 8080 POST / HTTP/1.1 Host: 192.168.0.16:8080 Connection: Keep-Alive User-Agent: PHP-SOAP/5.2.0-8+etch11 Content-Type: text/xml; charset=utf-8 SOAPAction: "getMetadata" Content-Length: 307 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://192.168.0.16:8080"><SOAP-ENV:Body><ns1:getMetadataRequest><oldname>oldname</oldname><newname>newname</newname></ns1:getMetadataRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
If you have any ideas, suggestions, I'll take it
Thanks in advance
--regards
Greg
Comment