我正在尝试进行身份验证并在Soap请求中得到响应,我尝试了其他选项,但无法获得任何结果。 这是xml必须采用的格式:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<UserCredentials xmlns="http://www.wtvision.com/sportsmanager">
<userName>string</userName>
<password>string</password>
<appName>string</appName>
<instance>string</instance>
</UserCredentials>
</soap:Header>
<soap:Body>
<GetGames xmlns="http://www.wtvision.com/sportsmanager">
<competitionKeyName>string</competitionKeyName>
</GetGames>
</soap:Body>
</soap:Envelope>
这是我的代码:
$url="http://sportsmanager.wtvision.com/SportStatsCenterV4/SportStatsCenterInfoServiceV4.asmx?WSDL";
try{
$auth = array(
'username' => 'xxxxx',
'password' => 'xxxxx',
);
$ns = 'http://www.wtvision.com/sportsmanager';
$client = new SoapClient($url);
$header = new SOAPHeader($ns, 'UserCredentials', $auth);
$client->__setSoapHeaders($header);
print_r($client->__getLastRequest());
$result = $client->GetGames();
echo '<h2>Response</h2>';
echo "<pre>".print_r($result, true)."</pre>";
}
catch(Exception $e){
echo $e->getMessage();
}
我得到的唯一答复是
System.Web.Services.Protocols.SoapException: Invalid authentication for user . at SportStatsCenterInfoService.ThrowError(String competitionKeyName, String requestName, String errorMessage) in c:\inetpub\wwwroot\SportStatsCenterV4\App_Code\SportStatsCenterInfoService.cs:line 146 at SportStatsCenterInfoService.GetGames(String competitionKeyName) in c:\inetpub\wwwroot\SportStatsCenterV4\App_Code\SportStatsCenterInfoService.cs:line 558