By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,319 Members | 1,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,319 IT Pros & Developers. It's quick & easy.

problem client soap(php) with server gsoap (c)

P: 5
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...) :

Expand|Select|Wrap|Line Numbers
  1. SoapFault exception: [SOAP-ENV:Client] Method 'ns1:getMetadataRequest' not implemented: method name or namespace not recognized in beta_2/soap.php:26
  2. Stack trace:
  3. #0 /root/src/rxtxws/beta_2/soap.php(26): SoapClient->__soapCall('getMetadata', Array)
  4. #1 {main}
And when I run the server, I have this:
Expand|Select|Wrap|Line Numbers
  1. Socket connection successful: master socket = 3
  2. SOAP 1.1 fault: SOAP-ENV:Client [no subcode]
  3. "Method 'ns1:getMetadataRequest' not implemented: method name or namespace not recognized"
  4. Detail: [no detail]
  5.  
My wsdl file seems well:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- partie 1 : Definitions -->
  3. <wsdl:definitions
  4.     targetNamespace="http://192.168.0.16:8080"
  5.     xmlns:typens="http://192.168.0.16:8080"
  6.     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  7.     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  8.     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  9.     xmlns="http://schemas.xmlsoap.org/wsdl/">
  10.  
  11. <!-- partie 2 : Types-->
  12.     <wsdl:types>
  13.       <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://192.168.0.16:8080">
  14.          <xsd:element name="getMetadataRequest">
  15.             <xsd:complexType>
  16.                <xsd:sequence>
  17.                   <xsd:element name="oldname" type="xsd:string" />
  18.                   <xsd:element name="newname" type="xsd:string" />
  19.                </xsd:sequence>
  20.             </xsd:complexType>
  21.          </xsd:element>
  22.  
  23.          <xsd:element name="getMetadataResponse">
  24.             <xsd:complexType>
  25.                <xsd:sequence>
  26.                   <xsd:element name="answer" type="xsd:string"/>
  27.                </xsd:sequence>
  28.             </xsd:complexType>
  29.          </xsd:element>
  30.         </xsd:schema>
  31.     </wsdl:types>
  32.  
  33.         <!-- partie 3 : Message -->
  34.     <wsdl:message name="getMetadataRequestMessage">
  35.         <wsdl:part name="input" element="typens:getMetadataRequest"/>
  36.     </wsdl:message>
  37.     <wsdl:message name="getMetadataResponseMessage">
  38.         <wsdl:part name="output" element="typens:getMetadataResponse"/>
  39.     </wsdl:message>
  40.  
  41.  
  42.         <!-- partie 4 : Port Type -->
  43.     <wsdl:portType name="WebServicesPortType">
  44.                 <!-- partie 5 : Operation -->
  45.         <wsdl:operation name="getMetadata">
  46.             <wsdl:input message="typens:getMetadataRequestMessage"/>
  47.             <wsdl:output message="typens:getMetadataResponseMessage"/>
  48.         </wsdl:operation>
  49.     </wsdl:portType>
  50.  
  51.         <!-- partie 6 : Binding -->
  52.     <binding name="WebServicesBinding" type="typens:WebServicesPortType">
  53.         <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
  54.         <wsdl:operation name="getMetadata">
  55.             <soap:operation soapAction="getMetadata"/>
  56.             <wsdl:input><soap:body use="literal"/></wsdl:input>
  57.             <wsdl:output><soap:body use="literal"/></wsdl:output>
  58.         </wsdl:operation>
  59.     </binding>
  60.  
  61.         <!-- partie 7 : Service -->
  62.     <wsdl:service name="WebServices">
  63.                 <!-- partie 8 : Port -->
  64.         <wsdl:port name="WebServicesPort" binding="typens:WebServicesBinding">
  65.             <soap:address location="http://192.168.0.16:8080"/>
  66.         </wsdl:port>
  67. </wsdl:service>
  68. </wsdl:definitions>
  69.  
So I think my problem is in client.php, but, i don't find it:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once 'SOAP/Client.php';
  3. ini_set("soap.wsdl_cache_enabled", FALSE);
  4. $wsdl_file =  'file.wsdl';
  5.  
  6. class getMetadataRequest
  7. {
  8.    public $oldname;
  9.    public $newname;
  10.    public function __construct( $oldname, $newname )
  11.    {
  12.       $this->oldname = $oldname;
  13.       $this->newname = $newname;
  14.    }
  15.  
  16. }
  17.  
  18. try {
  19.    $classmap = array('getMetadataRequest' => 'oldname', 'getMetadataRequest' => 'newname');
  20.    $soapClient = new SoapClient($wsdl_file, array('classmap' => $classmap, 'exception' => true, 'trace' => true));
  21.  
  22.       $oldname = "oldname";
  23.       $newname = "newname";
  24.  
  25.       $getMetadataRequest = new getMetadataRequest($oldname, $newname );
  26.       $getMetadataResponse = $soapClient->__soapCall(getMetadata, array($getMetadataRequest));
  27.       /* $getMetadataResponse = $soapClient->getMetadata($getMetadataRequest); */
  28.       $result = $getMetadataResponse->answer;
  29.       echo $result;
  30.    }
  31. catch (SoapFault $fault)
  32. {
  33.    echo $fault."\n";
  34. }
  35.  
  36. ?>
  37.  
A test with nc show me some informations are received, but...
Expand|Select|Wrap|Line Numbers
  1. $nc -l -p 8080
  2. POST / HTTP/1.1
  3. Host: 192.168.0.16:8080
  4. Connection: Keep-Alive
  5. User-Agent: PHP-SOAP/5.2.0-8+etch11
  6. Content-Type: text/xml; charset=utf-8
  7. SOAPAction: "getMetadata"
  8. Content-Length: 307
  9.  
  10. <?xml version="1.0" encoding="UTF-8"?>
  11. <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>
  12.  

If you have any ideas, suggestions, I'll take it
Thanks in advance

--regards
Greg
Jul 29 '08 #1
Share this Question
Share on Google+
4 Replies


P: 5
arg, shame on me.

Don't forget to check nsmap file. If ip/host aren't consistent, it can't work....

Sorry for that.

--
regards
Greg
Jul 29 '08 #2

P: 2
good day, i have problem too, but the error is "method not implemented or namespace not recognized".. does this have something to do with nsmap? by the way what is nsmap? can you detail me the solution? thanks..
Mar 25 '10 #3

Dormilich
Expert Mod 5K+
P: 8,639
Iím not doing much SOAP, but the nsmap refers to (I think) to the namespace mapping (one of the features of XML), if both parties (sender/receiver) donít use the same namespaces, the XML just wonít match.
Mar 25 '10 #4

P: 2
oks, thanks to all.. i got now what im looking for, gcharbon helped a lot
Mar 30 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.