WebServiceBindingAttribute Required Exception
If you run an ASP.NET client application that calls a web service via a client proxy, you may get an exception: "WebServiceBindingAttribute is required on proxy classes". This will of course occur in the trivial case where you have not decorated your proxy class with [System.Web.Services.WebServiceBindingAttribute(Nam e="...", Namespace="...")].
However, the exception may still be thrown even if you have decorated your class with the attribute. You may note that it does so when you are inheriting from the Microsoft.Web.Services2.WebServicesClientProtocol class. If you inherit instead from the System.Web.Services.Protocols.SoapHttpClientProtoc ol, then the problem will disappear.
But another problem will appear if you are planning on using WS-Security or any of the other WS-... capabilties provided in the WSE2 framework. In order to effect WS-..., you must access the RequestSoapContext property, and this property is only accessible if the proxy class inherits from Microsoft.Web.Services2.WebServicesClientProtocol.
I have noted however that you can decorate with the attribute and inherit from the WebServicesClientProtocol class without getting an exception thrown .... if you call the proxy class from a web application as opposed to a console application. I would need to investigate further to find out why this is so!
|