3

I have working PHP code which calls a SOAP service and it works. Its as follows:

<?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;
}
?>

I need to access the same service from C#. I have tried adding Service Reference to http://108-168-196-91.mycitrixdemo.net/zdm/services/EveryWanDevice?wsdl and this added the following section in my 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>

I am now provided with the proxy classes but I dont know how to set them up so I could call this service.

I am doing it as follows in C#:

DeviceService srv = new DeviceServiceClient();//
srv.authenticateUser(new authenticateUserRequest("Admin", "XXXXXX"));

var devices = srv.getDeviceProperties(new getDevicePropertiesRequest("99000067296308", null));

But the srv.authenticateUser line throws the following exception:

RPC Message getDeploymentHistoRequest1 in operation getDeploymentHisto1 has an invalid body name getDeploymentHisto. It must be getDeploymentHisto1

I have no idea what does this error mean. Can anybody help?

Aamir
  • 1,747
  • 5
  • 26
  • 50

2 Answers2

4

This is due to using a WCF reference versus a standard service reference.

Take a look at WCF: Svcutil generates invalid client proxy, Apache AXIS Web Service, overload operations for further discussion.

In short, use Add Web Reference on the Advanced page of Add Service Reference:

Add Web Reference

Community
  • 1
  • 1
Mitch
  • 21,223
  • 6
  • 63
  • 86
1

To me this error looks like an issue with generating your proxy file. You probably want to re-proxy by using svcutil to make sure your proxy file is being generated correctly. In your case, the command in your Visual Studio Developer Command tool would look like so...

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

It also doesn't look like you're establishing a secure session in the first Place. Change your binding to the following...

<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>

The vast majority of that are just basic defaults for a service binding. The security part is what should let you establish a secure connection to the service like so...

var srv = new DeviceServiceClient();

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

Finally you can call the getDeviceProperties method with your arguments and get some sort of a response back.

gfish3000
  • 1,557
  • 1
  • 11
  • 22