开发者

.NET WebService WebMethod with custom object as Parameter

I have created a .NET WebService. There I have implemented the following WebMethod:

[WebMethod]
public string CheckLicense(License license) {
    return "";
}

The Type License comes from a different Assembly X which I have referenced to the WebService. The Fulltype of License is Prayon.Shared.Library.Licensing.License

Now, I have build a client which also references the Assembly X. When I try no to call the WebService with CheckLincense:

    private void CheckLicense(License license) {开发者_C百科
        using(var service = new Prayon.Service.Web.PrayonService()) {
            service.CheckLicense(license);
        }
    }

There service.CheckLicense() want an object of Type Prayon.Service.Prayon.Service.Web.License. I don't know what I am doing wrong. What does I have to do, that I can pass a object of Type Prayon.Shared.Library.Licensing.License to service.CheckLicense()?


If you want to use a method in your License object you need to : Call your WebService, obtain a service.License object, use it to create an instance of your local License object, after that you will have your 'local' License object with state (properties) filled by your WebService answer. Otherwise i do not see why you would want to use a 'local' License object ?


You should not share the assembly between your web service and your client but instead create an instance of your License from your web service proxy types (should be found into service.x)


You need to create an instance from the webserviceproxy rather than from the asembly. When you add a service reference to your webserice from the client it will generate proxy classes for you.Inside these you will have the License defined.use this to create an instance and pass it rather than referencing directly from your assembly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜