2014-03-31 1 views
3

SOAP 서비스를 호출하는 PHP 코드가 작동하며 작동합니다. 그것의 다음과 같습니다 :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 Referencehttp://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 

나는이 오류가 의미합니까 무엇인지 전혀 모른다. 아무도 도와 줄 수 있니?

답변

1

는 나에게이 오류는 프록시 파일을 생성에 문제처럼 보인다. 프록시 파일이 올바르게 생성되었는지 확인하려면 svcutil을 사용하여 다시 프록시 할 수 있습니다. 귀하의 경우에는, 당신의 비주얼 스튜디오 개발자 명령 도구의 명령은 ...과 같이 첫 번째 장소에서 보안 세션을 확립하는 것처럼 그것은 또한 보이지 않는

svcutil.exe /language:cs /out:Proxies.cs /config:output.config [service url] 

을 보일 것이다. 바인딩을 다음으로 변경하십시오 ...

<binding name="EveryWanDeviceSoapBinding" 
     closeTimeout="00:01:00" 
     openTimeout="00:01:00" 
     receiveTimeout="00:10:00" 
     sendTimeout="00:01:00" 
     allowCookies="false" 
     bypassProxyOnLocal="false" 
     hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="6553666" 
     maxBufferPoolSize="524288" 
     maxReceivedMessageSize="6553666" 
     messageEncoding="Text" 
     textEncoding="utf-8" 
     transferMode="Buffered" 
     useDefaultWebProxy="true"> 
    <security mode="Transport"> 
     <transport clientCredentialType="Basic" 
        proxyCredentialType="Basic" 
        realm="" /> 
     <message clientCredentialType="UserName" 
       algorithmSuite="Default" /> 
    </security> 
</binding> 

대다수는 서비스 바인딩의 기본 기본값입니다. security 부분은

var srv = new DeviceServiceClient(); 

srv.ClientCreditials.UserName.UserName = "Admin"; 
srv.ClientCreditials.UserName.Password = "XXXXX"; 

마지막으로 당신이 당신의 인수를 사용하여 getDeviceProperties 메서드를 호출 할 수 있습니다 다시 응답의 어떤 종류를 얻을 수 ... 당신이 그렇게 같은 서비스에 대한 보안 연결을 설정하도록해야하는 것이다.