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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gcharbon
    New Member
    • Jul 2008
    • 5

    #1

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

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

    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}
    And when I run the server, I have this:
    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]
    My wsdl file seems well:
    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>
    So I think my problem is in client.php, but, i don't find it:

    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";
    }
    
    ?>
    A test with nc show me some informations are received, but...
    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
    Last edited by gcharbon; Jul 29 '08, 10:21 AM. Reason: forget informations
  • gcharbon
    New Member
    • Jul 2008
    • 5

    #2
    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

    Comment

    • mikemike28
      New Member
      • Mar 2010
      • 2

      #3
      pls you detail me the solution

      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..

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        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.

        Comment

        • mikemike28
          New Member
          • Mar 2010
          • 2

          #5
          oks, thanks to all.. i got now what im looking for, gcharbon helped a lot

          Comment

          Working...