0

Ok, I'm tearing my hair out on this one. I've not worked with a PHP WDSL SOAP CURL XML call at all (all of them individually but not together!) and struggling to get a response or a meaningful error.

To highlight it, I have a demo WDSL endpoint (http://office.keystonesupport.net:8084/DemoSoap/KSDSoap/KhaosKSD.exe/wsdl/IKosWeb?wsdl) that, if you stick in a browser, will respond with an XML detailing everything.

I then tried writing the PHP to access one specific operation 'GetVersion' that takes no input parameters

Posting using Wizdler (https://chrome.google.com/webstore/detail/wizdler/oebpmncolmhiapingjaagmapififiakb), it shows that with the request headers

SOAPAction: "urn:IKosWebIntf-IKosWeb#GetVersion"
Content-Type: text/xml; charset="utf-8"

and the body

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
        <Body>
            <GetVersion xmlns="http://tempuri.org/"/>
        </Body>
    </Envelope>

I get the response

<?xml version="1.0"?>
    <SOAP-ENV:Envelope 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/">
        <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS1="urn:IKosWebIntf-IKosWeb">
            <NS1:GetVersionResponse>
                <return xsi:type="xsd:string">8.149.29</return>
            </NS1:GetVersionResponse>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

So I put this into my script, below. But it just gives the curl timeout error?

$xml='<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
        <Body>
            <GetVersion xmlns="http://tempuri.org/"/>
        </Body>
    </Envelope>';
 $url='http://office.keystonesupport.net:8084/DemoSoap/KSDSoap/KhaosKSD.exe/wsdl/IKosWeb?wsdl';

    $ch = curl_init();
    $headers = array(
            "Content-type: text/xml;charset=\"utf-8\"",
            "SOAPAction:  \"urn:IKosWebIntf-IKosWeb#GetVersion"",
        );
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
        curl_setopt($ch, CURLOPT_URL,            $url );
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
        curl_setopt($ch, CURLOPT_POST,           true );
        curl_setopt($ch, CURLOPT_POSTFIELDS,     $xml);
        curl_setopt($ch, CURLOPT_HTTPHEADER,     $headers);


    print_r ($headers);
    echo '<br>';
    echo htmlentities($xml);
    echo '<br>';
    $response = curl_exec($ch);
    if($response === false) {
            $err = 'Curl error: ' . curl_error($ch);
            curl_close($ch);
            print $err;
        }else{
    curl_close($ch);
    var_dump($response);
    }

2 Answers 2

2

There seems to by a syntax error on line

 "SOAPAction:  \"urn:IKosWebIntf-IKosWeb#GetVersion"",

It should be

 "SOAPAction:  \"urn:IKosWebIntf-IKosWeb#GetVersion\"",

After fixing this, the code was working for me.

LE: In the end it turns out that the problem was the port 8084 was filter/blocked by ISP. So, "Connection time out" was because of this.

Sign up to request clarification or add additional context in comments.

3 Comments

What response do you get back? I made that change but just get 'Curl error: Failed to connect to office.keystonesupport.net port 8084: Connection timed out'
It is quite long, stack overflow complains "too long by 54059 characters". Starts with: Array ( [0] => Content-type: text/xml;charset="utf-8" [1] => SOAPAction: "urn:IKosWebIntf-IKosWeb#GetVersion" ) <br>&lt;Envelope xmlns=&quot;schemas.xmlsoap.org/soap/envelope/&quot;&gt; &lt;Body&gt; &lt;GetVersion xmlns=&quot;tempuri.org/&quot;/&gt; &lt;/Body&gt; &lt;/Envelope&gt;<br>string(54275) "<?xml version="1.0"?>
I assume that there is a problem with port 8084, probable it is blocked on some router/proxy. Try from command line telnet office.keystonesupport.net 8084 , if it works you will see at the end the message Escape character is '^]'. . If it dosn't work (port blocked), last line will be telnet: Unable to connect to remote host: Resource temporarily unavailable
0

Thanks to Marcel Preda, they narrowed it down for me. Turns out the code was fine (apart from the one syntax error) but it was a blocked port from my service provider.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.