0

I got an error message when trying to call a web service in php : SoapFault exception: [VersionMismatch] Wrong Version.

But when i execute the result of $client->__getLastRequest() in SOAP UI, the fonction runs well onserver side..

Here is my wsdl (i replaced my server name by localhost) :

<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:tns="urn:PDF_API" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    targetNamespace="urn:PDF_API"
>
<types>
    <xsd:schema targetNamespace="urn:PDF_API"></xsd:schema>
</types>
<message name="html_to_pdf_request">
  <part name="html" type="xsd:string" />
</message>
<message name="html_to_pdf_response">
  <part name="pdf" type="xsd:string" />
</message>
<portType name="PDF_API_PortType">
  <operation name="html_to_pdf">
    <documentation>Convertit le HTML en format PDF</documentation>
    <input message="tns:html_to_pdf_request"/>
    <output message="tns:html_to_pdf_response"/>
  </operation>
</portType>
<binding name="PDF_API_Binding" type="tns:PDF_API_PortType">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="html_to_pdf">
    <soap:operation soapAction="urn:html_to_pdf2/html_to_pdf" style="rpc"/>
    <input><soap:body use="encoded" namespace="urn:html_to_pdf2" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
    <output><soap:body use="encoded" namespace="urn:html_to_pdf2" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
  </operation>
</binding>
<service name="PDF_API">
  <port name="PDF_API_Port" binding="tns:PDF_API_Binding">
    <soap:address location="http://localhost/PDF_API/PDF_API.php"/>
  </port>
</service>
</definitions>  

I call the web service like this

try{
            $client = new SoapClient(
                                    pdfApiWSDL,
                                    array(
                                        'soap_version'   => SOAP_1_1,
                                        'cache_wsdl' => WSDL_CACHE_NONE,
                                        'trace'=>1)
                                    );

            $client->__setLocation(pdfApiWSDL);
                        $res = $client->html_to_pdf('test');


        } catch (Exception $e) {

        }

Here is my envelope :

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:html_to_pdf2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
    <env:Body>
        <ns1:html_to_pdf env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
            <html xsi:type="xsd:string">test

            </html>
        </ns1:html_to_pdf>
    </env:Body>
</env:Envelope>

I have already checked Does this SOAP Fault mean what I think it means? but nothing helped

EDIT

Problem solved, the error message was confusing ! I just changed link to wsdl from

http://myserver/PDF_API/PDF_API.php.wsdl

to

http://myserver/PDF_API/PDF_API.php?wsdl

... and then magic happened.

Rick31
  • 89
  • 12

0 Answers0