0
我想用wsdl使用php(5.3.5)來訪問webservice(JAX-WS)。以下是我使用的代碼:PHP SoapClient調用soap身份驗證方法
class insoapauth
{
public $Username;
public $Password;
public function __construct($username, $pass)
{
$this->Username = $username;
$this->Password = $pass;
}
}
$client = new SoapClient("http://192.168.124.11:8080/cx-subscriberdata/CXSubscriberAdmin?wsdl", array("login" => "SOAPDW", "password" => "[email protected]"));
// Create the header
$auth = new insoapauth("SOAPDW", "[email protected]");
$header = new SoapHeader("http://192.168.124.11:8080/cx-subscriberdata/CXSubscriberAdmin", "APICredentials", $auth, false);
try {
$result = $client->__soapCall("getDataWS", array(
"CrmSearchInformation" => array(
"searchKeyValue" => "93700801021"
)
));
echo("<br/>Returning value of __soapCall() call: ".$result);
}catch(SoapFault $exception)
{
print_r("Got issue:<br/>") ;
var_dump($exception);
}
或者我嘗試使用SOAPHEADER並且在方法調用提供另一種方式。但我總是得到的SOAPFault例外:
無法連接到主機
更多細節例外:
的SOAPFault例外:[HTTP]無法連接在 C到主機:\ wamp \ www \ SOAPTest \ client \ insoaptest.php:103堆棧跟蹤:#0 [內部函數]:SoapClient - > _ doRequest(' _soapCall('getDataWS', Array)#2 {main }
但是,使用soapUI我可以連接到soapsever,並可以使用相同的憑據調用soapmethod。 以下是一些示例代碼來訪問WS - 我想這是在Java的隨附手冊:
INBeanService service = new INBeanService();
CXINWS wsPort = service.getCXINWSPort();
String username = "crmtestuser";
String password = "crmpassword";
BindingProvider bp = (BindingProvider) wsPort;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
try {
CrmSearchInformation crmSearchInfo = new CrmSearchInformation();
crmSearchInfo.setSearchKeyValue(msisdn);
CrmSearchResult result = wsPort.getDataWS(crmSearchInfo);
//handle result
System.out.println("Result state: " + result.getSearchResultState());
} catch (NxWsException e) {
// handle exceptions
}
可有人請告訴我一些光我如何從PHP訪問web服務的WSDL與認證?
所以
文檔,你說我的代碼就可以了? – marifrahman 2012-03-13 13:18:22
不,仍然沒有運氣:| – marifrahman 2012-03-14 06:39:20
沒有人幫助我? – marifrahman 2012-03-15 04:09:22