SOAP:将用户名和密码添加到soap:address位置URL不起作用?

时间:2018-11-02 10:15:21

标签: php soap soap-client

当我卷曲此 url 时,它会起作用:

# dat <- as.factor(dat); dat

# 2011-11-11 2011-06-01 1974       1970       2003-09-16
# Levels: 1970 1974 2003-09-16 2011-06-01 2011-11-11

as.Date(sub("(^[0-9]{4}$)", "\\1-01-01", dat))

# "2011-11-11" "2011-06-01" "1974-01-01" "1970-01-01" "2003-09-16"

但是,当我这样在我的肥皂地址中调用它时,它不起作用:

curl http://OLM:OLM794%24@X.XXX.XXX.XXX:10080

它向我显示:<soap:address location="http://OLM:OLM794%24@X.XXX.XXX.XXX:10080/"/>

您知道为什么吗?

更新:

(SoapFault): Authorization Required

sw.xml

然后在我的文件中调用该肥皂:

.... <wsdl:service name="Toto"> <wsdl:port name="GazListeImpayesHttpSoap11Endpoint" binding="tns:TotoSoap11Binding"> <soap:address location="http://OLM:OLM794%24@X.XXX.XXX.XXX:10080/web/services/Toto.TotoHttpSoap11Endpoint/"/> </wsdl:port> </wsdl:service> </wsdl:definitions>

file.php

结果:

<?php
$soap = new SoapClient('http://domaine.com/sw.xml');

var_dump($soap->__getFunctions()); //OK
var_dump($soap->__getTypes()); //OK

$result = $soap->__soapCall("method", array("parameters"=>array("args0"=>array("NUM"=> "123"))));
var_dump($result);
?>

1 个答案:

答案 0 :(得分:1)

我找到了解决方案,用户和密码应该添加在SoapClient方法中,而不是直接在wsdl soap:address location

中添加

像这样:

$user = "your user here";
$password = "your password here";
$url = "path of wsdl location here";
$credentials = array(
    'login' => $user,
    'password' => $password,
);

$soap = new SoapClient($url, $credentials);