使用php执行curl
我可以像这样使用java调用soap服务器
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, "");
但我的问题是如何使用curl和php调用相同的函数,我已经尝试过这个,但它可能是某种有趣的代码
$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);
但它回显http代码100,我这样做未从肥皂服务器找到任何结果。但我的soap服务器没问题,通过java测试。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说看起来不错,除了 CURLOPT_HEADER 需要为 true 或 false(是否在输出中包含 HTTP 标头),
应该是
我只能猜测确认密码是什么,如果它是回调,则应该使用 CURLOPT_HEADERFUNCTION 代替。
但正如 Ariel 指出的,你没有告诉我们问题是什么。
Looks fine to me, except CURLOPT_HEADER needs to be either true or false (include HTTP header in output or not),
should be
I can only guess what confirmPassword is, if it's a callback, you should use CURLOPT_HEADERFUNCTION instead.
But as Ariel pointed out, you're not telling us what the problem is.
尝试删除这一行:
然后发布输出是什么。
Try removing this line:
Then post what the output is.