our software uses many WebService calls via
sc = new MyServiceSoapClient()
and this contructor reads EndpointAddress and Binding and Behavior from Winword.exe.config (this is because out software is a winword Addin)
But the customer demands that we dont touch the Winword.exe.config file.
So we changed our strategy to create a channel from a ChannelFactory because in this case we can use any ".config" file we like.
unfortunatedly the channel we get from the ChannelFactory is a "MyServiceSoap" but it is not a "MyServiceSoapClient".
We dont want to do each WebService call via the created channel because this would imply that we re-implemented very many calls like this:
creating a request object
calling the WebService Method
reading the result from the response object.
so we tried to instanciate the MyServiceSoapClient this way:
sc = new MyServiceSoapClient(chfact.Endpoint.Binding, chfact.Endpoint.Address)
this worked fine, we finally got our SoapClient out of any ".config" file and we were not depending on the Winword.exe.config file.
but then the customer added some Behavior to the config file because of security reasons.
well, the channelFactory certainly reads the Behavior from the config file but there is no constructor like this:
sc = new MyServiceSoapClient(Binding, Address, Behavior)
so we cannot create a FULLY VALID MyServiceSoapClient from an existing MyServiceSoap-channel.
The Behavior works fine if we created the MyServiceSoapClient with it's default constructor - but then the customer would need to configure the Winword.exe.config what he denies to do.
It is also impossible to typecast like this:
sc=(MyServiceSoapClient)channel;
because channel is a MyServiceSoap interface.
QUESTION:
Is there any way to create a MyServiceSoapClient from a MyServiceSoap-channel or from a channelFactory ?
Or can it be done with some sophisticated Type-Casting?
many thanks in advance
yours, Gerald