0

I can call a soap server using java like this

        Call call = new Call();
        URL url = new URL("http://soap-something.dash.com/servlet/rpcrouter");
        call.setTargetObjectURI("urn:login-transport");
        call.setMethodName("confirmPassword");
        call.setParams(a vector);
        resp = call.invoke(url, "");

But my question is how can I call this same function using curl and php, I have already tried this, but it may be some kind of funny code

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://soap-something.dash.com/servlet/rpcrouter?urn:login-transport");
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HEADERFUNCTION, "confirmPassword");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>"pritom", "password"=>"pritom"));
    $head = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    echo "<br/>HTTP CODE: " . $httpCode;
    print_r($head);

But it echo http code 100 and I do not found any result from soap server. But my soap server is ok, tested by java.

4

2 回答 2

0

尝试删除此行:

curl_setopt($ch, CURLOPT_NOBODY, false); // remove body

然后发布输出是什么。

于 2012-01-17T08:53:26.593 回答
0

对我来说看起来不错,除了 CURLOPT_HEADER 需要为真或假(在输出中是否包含 HTTP 标头),

curl_setopt($ch, CURLOPT_HEADER, "confirmPassword");

应该

curl_setopt($ch, CURLOPT_HEADER, true);

我只能猜测 confirmPassword 是什么,如果是回调,你应该使用 CURLOPT_HEADERFUNCTION 代替。

但正如 Ariel 指出的那样,您并没有告诉我们问题出在哪里。

于 2012-01-08T11:41:24.430 回答