C# – Manually creating proxy for Web Service

cwcfweb serviceswsdl

I have to communicate (using .NET) with a web service running on Axis 1.2. Using two .NET tools and the WSDL I have created C# proxies however I ran into problems such that:

1) WSDL.exe created a proxy which lacks input parameters for methods. e.g. if there should be such a method:

AReturnType AMethod(AnInputType);

the created proxy had such a method:

void AMethod();

2) I've read that instead of WSDL.exe, SVCUTIL.exe is recommended. So I've created the proxies with SVCUTIL, however ran into the infamous problem of NULL returned objects. Unfortunately I could not find any suitable solution.

So I am willing to do the setup manually. Here's what I have:

  • SoapUI parses the WSDL well, can inspect SOAP/XML requests/responses.
  • Axis WSDL2JAVA generates proper Java code, and it works well
  • Sending XML/SOAP requests with HttpWebRequest generates proper XML/SOAP responses.
  • I have tried generating XSD and C# objects using XSD.EXE tools and serializing XML responses (obtained with previous step) into those objects.

So what do you suggest? Is there a way to manually create the proxy somehow? Or can generated Java code help me somehow?

Best Answer

Here's how a project I'm working on creates and uses a manual proxy.

This is the client proxy:

 [ServiceContract(Name = "YourServiceContract", Namespace = "http://....")]
 public interface YourServiceContract, 
  {
    [OperationContract]
    object GetObject(object searchCriteria);
   }

public class YourClient : ClientBase<YourServiceContract>, YourServiceContract
{
    public YourClient (){ }

    public YourClient (string endpointConfigurationName)
    : base(endpointConfigurationName){ }

    public object GetObject(object searchCriteria)
    {
    return base.Channel.GetObject(searchCriteria);
    }
}

This is how it's called:

public void GetYourObject(object searchCriteria)
    {
        YourClient proxy = new YourClient();
        proxy.GetObject(searchCriteria);
        proxy.SafeClose();
    }
Related Topic