PDA

View Full Version : WebServiceClientProxy doesn't implement my interface


EJS
11-03-2006, 03:05 PM
Hi all,

I configured an object of type WebServiceProxyFactory to wrap a proxy implementing a service interface. Implementation is quite basic, much like the provided examples. The interface has one method of the same signature as the proxy class.

When running my code:

IApplicationContext ctx = ContextRegistry.GetContext();
MyService service = (MyService ) ctx["wrappedProxy"];

I get an InvalidCastException stating this object can't be casted to MyService. The object doesn't (seem to) implement the MyService interface.

When looking at the WebServiceProxyFactory code (nightly build 20061025) I can't understand how this should work...

The WebServiceClientProxyTypeBuilder inner class is instantiated with the serviceInterface (of type Type) specified in the configuration. Then serviceInterface.GetInterfaces() is called to get the interfaces to implement. But this call returns an empty array because MyService itself doesn't implement or extend any interfaces... So for simple interfaces like mine this will always be empty? Am I missing the point here?
:confused:

Any clarifications appreciated....!

Thanks,
EJ

Bruno Baia
11-05-2006, 11:38 PM
Hi,


IApplicationContext ctx = ContextRegistry.GetContext();
MyService service = (MyService ) ctx["wrappedProxy"];

I get an InvalidCastException stating this object can't be casted to MyService.

U mean :

MyService service = (MyService ) ctx.GetObject("wrappedProxy");

:p


The WebServiceClientProxyTypeBuilder inner class is instantiated with the serviceInterface (of type Type) specified in the configuration. Then serviceInterface.GetInterfaces() is called to get the interfaces to implement. But this call returns an empty array because MyService itself doesn't implement or extend any interfaces... So for simple interfaces like mine this will always be empty?
Is MyService the interface definition or the implementation ?
Can you post the "wrappedProxy" object definition ?


Cheers,
Bruno

EJS
11-06-2006, 05:04 PM
I admit... a very sloppy problem description... must have been Friday ;-)

MyService is the service interface definition.

<object id="wrappedProxy" type="Spring.Web.Services.WebServiceProxyFactory, Spring.Services">
<property name="ProxyClass" value="MyNamespace.Proxy, MyAssembly"/>
<property name="ServiceInterface" value="MyNamespace.MyService, MyAssembly"/>
</object>

MyNamespace.Proxy is a proxy generated using VS2005.

Cheers,
EJ

Bruno Baia
11-06-2006, 06:49 PM
Hi,

I think I forgot something when I refactored the dynamic proxy code.
I need to add it again, but this should work with an old version (1.1 P2).


But why are you not using WebServiceClientFactory ?
It generates the proxy dynamically, you don't need to generate it using VS2005

<object id="calculatorService" type="Spring.Web.Services.WebServiceClientFactory, Spring.Services">
<property name="ServiceUrl" value="http://localhost:1643/Spring.Calculator.Web.2005/calculatorService.asmx"/>
<property name="ServiceInterface" value="Spring.Calculator.Interfaces.IAdvancedCalculator, Spring.Calculator.Contract"/>
</object>




- Bruno

EJS
11-06-2006, 07:26 PM
Hi Bruno,

Thanks. I hadn't really made up my mind yet as to which version (dynamic or static) to use. I'll be using this functionality as part of a webservice that calls another webservice.

The dynamic version will be recreated every time the application context restarts. Just felt this might cause extra problems, e.g. when the remote webservice would be temporarily unavailable. Yes, in that case of course neither a call through the proxy would succeed, but that would not prevent the application context from starting up correctly.

How do you see this?

EJ

Bruno Baia
11-06-2006, 11:47 PM
Hi,

the proxy is not generated when the context is loaded but when it is accessed for the first time.

Anyway I planned to support local wsdl file in WebServiceClientFactory ( there should be a TODO coment somewhere in the code :) ), so we'll get the same behavior than using VS2005 generated proxy.

- Bruno

Bruno Baia
11-14-2006, 01:34 AM
Hi,

I fixed the WebServiceProxyFactory to work like in the 1.1 P2.
Give a try to the latest nightly build.

Sorry for the mess,
Bruno

EJS
11-14-2006, 09:31 PM
Sorry for the mess,
Bruno
No ... 'au contraire' (excuse my french) ;) thanks for the good work and support!

Anyway, I come across a problem (using nightly build 20061113). I was using a ProxyClass property in my config, and saw you changed it's name into ProxyType. However, changing the property name didn't fix my error:

[Spring.Objects.TypeMismatchException: Cannot convert property value of type [System.String] to required type [System.Type] for property 'ProxyType'., Inner Exception: System.TypeLoadException: Could not load type from string value 'EJSSD.LJNService.Client.LJNServiceProxy.LjnServic e, EJSSD.LJNService.Client'.

Furthermore the error message reveals a path that's not on my local machine, so I'm a bit confused:
at Spring.Util.TypeResolver.ResolveType(String typeName) in c:\projects\daily\Spring.Net\src\Spring\Spring.Cor e\Util\TypeResolver.cs:line 156

Cheers,
EJ

Bruno Baia
11-14-2006, 10:18 PM
Hi EJ,

sorry for the ProxyClass, I forgot to tell you I rename it to ProxyType.

About your error, it seems pretty clear :
Are you sure the type "'EJSSD.LJNService.Client.LJNServiceProxy.LjnServic e" exists in the assembly "EJSSD.LJNService.Client" ?


Bruno

EJS
11-14-2006, 10:34 PM
Yes, it's there... The problem was I didn't build the new nightly build.:rolleyes: I built it now, ProxyType problem gone, but now I have:

Error setting property values: 'Methods' node cannot be resolved for the specified root context. ---> Spring.Objects.InvalidPropertyException: 'Methods' node cannot be resolved for the specified root context
Methods is used in an object definition of type Spring.Web.Services.WebServiceExporter. A quick look at the code shows this is changed too? Can't immediately see what it's replaced by..

Cheers,
EJ

Bruno Baia
11-14-2006, 10:38 PM
Oups, we are renaming some stuffs for the 1.1 P3.

Take a look to this post :
http://forum.springframework.net/showpost.php?p=3740&postcount=3


Sorry for the mess,
Bruno

EJS
11-14-2006, 10:46 PM
OK, thanks.

EJ