Question

I have a Web Service which uses a specific type from a DLL that we have. So for example our Web Service solution in Visual Studio looks like this:

Solution
  ACMEWebService (proj)
  Utils (proj)

Then i have WebMethod in my ACMEWebService which expects a certain type that exists in the Util class. It looks something like this:

[WebMethod]
public void SomeWebMethod (int Id, CustomDateClass date)
{
    // my code here
}

So CustomDateClass is a class that is located in the Utils project. That Utils project simply builds to a DLL file.


My Client Application references the Web Service. What it does is that it generates a so called proxy class, looking something like this:

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://acme/Services")]
public partial class CustomDateClass {
    private short yearField;
    private byte monthField;

    public short Year {
        get {
            return this.yearField;
        }
        set {
            this.yearField = value;
        }
    }

    public byte Month {
        get {
            return this.monthField;
        }
        set {
            this.monthField = value;
        }
    }
}

[System.Web.Services.Protocols.SoapHeaderAttribute("CustomSoapHeaderValue")]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://acme/Services/SomeMethod" ...)]
public void SomeMethod(int id, CustomDateClass date) {
    object[] results = this.Invoke("SomeMethod", new object[] {
                id,
                date});
}

In that proxy class i also see the CustomDateClass class and the Web Method SomeWebMethod(int Id, CustomDateClass date).

The problem however is, is that this method from the proxy class doesn't expect a CustomDateClass object from the Utils DLL, but from the proxy class namespace...

Is there a way to force the Web Service to expose the type from the Utils DLL?

Then i can simply Reference the Utils.dll from my CLient App as well and pass that an object that is an instance from the Utils DLL back to the Web Service instead of the class that is referenced in the Proxy class like now.

Was it helpful?

Solution

In the proxy class generator (aka web service reference wizard) there is a checkbox to reuse existing types if possible. Reference your dll and update the web service reference with this checkbox enabled.

OTHER TIPS

You can add a reference of your Util dll to the Project having the proxy class. Then you can change the method signature to accept an object from your Util dll. If the class name and diagram inside your Util dll is similar to what the web service expects, then it should not be a problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top