我有工作的PHP代碼調用SOAP服務,它的工作原理。它如下:從C調用肥皂服務#
<?php
try
{
$client = new SoapClient(null, array(
'location' => "http://108-168-196-91.mycitrixdemo.net/zdm/services/EveryWanDevice?wsdl",
'uri' => "http://zdemo2.zenprise.com",
'login' => "Admin",
'password'=> "XXXXX"));
$properties=$client->getDeviceProperties("XXXXXXXX",null);
for($i=0;$i<count($properties);$i++) {
printf ("name: %s, value: %s\n" , $properties[$i]->name, $properties[$i]->value);
}
}
catch (Exception $e)
{
print_r($e); exit;
}
?>
我需要從C#訪問相同的服務。我曾嘗試將Service Reference
添加到http://108-168-196-91.mycitrixdemo.net/zdm/services/EveryWanDevice?wsdl
,並在我的app.config中添加了以下部分。
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="EveryWanDeviceSoapBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://108-168-196-91.mycitrixdemo.net/zdm/services/EveryWanDevice"
binding="basicHttpBinding" bindingConfiguration="EveryWanDeviceSoapBinding"
contract="ServiceReference1.DeviceService" name="EveryWanDevice" />
</client>
</system.serviceModel>
我現在提供了代理類,但我不知道如何設置它們以便我可以調用此服務。
我這樣做如下的C#:
DeviceService srv = new DeviceServiceClient();//
srv.authenticateUser(new authenticateUserRequest("Admin", "XXXXXX"));
var devices = srv.getDeviceProperties(new getDevicePropertiesRequest("99000067296308", null));
但srv.authenticateUser
行拋出以下異常:
RPC Message getDeploymentHistoRequest1 in operation getDeploymentHisto1 has an invalid body name getDeploymentHisto. It must be getDeploymentHisto1
我不知道這是什麼意思的錯誤。任何人都可以幫忙嗎?