tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raymond Feng" <enjoyj...@gmail.com>
Subject Re: using webservices transparent
Date Fri, 05 Jun 2009 15:40:16 GMT
We use JAXB internally to support POJO for WS/XML. The POJOs are mapped 
to/from XML following the JAXB rules. If you have an external WSDL/XSD, you 
are recommended to use wsimport tool to generate the Java interface which 
accurately represents the WSDL/XSD. Please see an example at:

https://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/samples/zipcode-jaxws/ 
(We actually use the same WS as you do :-).

Of course you can still handcraft the POJOs, but you might have to add a few 
JAXB annotations to map the namespaces. To unmarshal the XML into JAXB/POJO, 
if a property is not found, it is ignored. That's why you see the empty 
data.

Thanks,
Raymond
--------------------------------------------------
From: "Martin Thoma" <m.thoma@b2m-software.de>
Sent: Friday, June 05, 2009 4:42 AM
To: <user@tuscany.apache.org>
Subject: using webservices transparent

> Hello,
>
> I am trying to integrate an external web service(represented by WSDL) in a 
> SCA component within the Tuscany platform (Version 1.3.1). The web 
> services is specified as reference in the component composite, as well as 
> annotated in implementation code(see below). The example that I 
> implemented was similar to the xml-bigbank example in the tuscany 1.3.1 
> version. With the examples (see code below), I got different results. But 
> I want to use a transplant solution provided by the tuscany framework, 
> where I don't have to use generated stub code(e.g. from axis2 wsdl2java) 
> in the implementation(client) code.
>
> As a first step  I developed a external test webservice operated on axis2 
> server(outside the tuscany framework).
>
> To use this web service in the tuscany platform, I declared this 
> interface, which represents external web service(inside tuscany 
> framework):
>
>
> @Remotable
> public interface TestService{
> Result foo(Request r);
> }
>
>
>
> with Result and Request as normal POJO classes.
>
> The binding in client.composite:
> <reference name="testService">
> <binding.ws 
> wsdlElement="http://targetnamespace/#wsdl.port(TestService/TestServiceSoap)" 
> />
> </reference>
>
> the corresponding wsdl
> <?xml version="1.0" encoding="utf-8"?>
> <wsdl:definitions targetNamespace="http://targetnamespace/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> <wsdl:import namespace="http://targetnamespace/"
> location="http://localhost/testservice?wsdl" />
> </wsdl:definitions>
>
>
> the TestClient (implementation of remotable interface):
>
> @Reference
> protected TestService testService;
> ...
> Request r = new Request();
> Result rs = testService.foo(r);
>
>
> and everything works fine (no axis,axis2, etc. stuff in client code) ;-)
>
>
> Now I tried to integrate a foreign external webservice
>
> (URI: http://www.webservicex.net/WeatherForecast.asmx?wsdl):
>
> The interface:
> @Remotable
> public interface WeatherService  {
>    GetWeatherByPlaceNameResult GetWeatherByPlaceName(String placeName) 
> throws java.rmi.RemoteException;
> }
>
> and again with GetWeatherByPlaceNameResult as POJO class.
>
> The binding
>      <reference name="weather">
>        <binding.ws 
> wsdlElement="http://www.webservicex.net#wsdl.port(WeatherForecast/WeatherForecastSoap)"

> />
>     </reference>
>
> the corresponding wsdl
> <?xml version="1.0" encoding="utf-8"?>
>
> <wsdl:definitions targetNamespace="http://www.webservicex.net"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> <wsdl:import namespace="http://www.webservicex.net"
> location="http://www.webservicex.net/WeatherForecast.asmx?wsdl" />
> </wsdl:definitions>
>
> and the TestClient:
>
> @Reference
> protected WeatherService weather;
> ...
> GetWeatherByPlaceNameResult result = weather.GetWeatherByPlaceName("New 
> York");
> System.out.println(result.getPlaceName());
>
> but this time the POJO is always empty !
>
> If I changed the interface WeatherService to
>
> @Remotable
> public interface WeatherService  {
>      OMElement GetWeatherByPlaceName(String placeName) throws 
> java.rmi.RemoteException;
> }
>
> I got the data but this is not transparent anymore!
>
> Any ideas why the GetWeatherByPlaceNameResult object is always empty ?
>
>
> Mit freundlichem Gruß / Kind regards
>
> Martin Thoma
> 

Mime
View raw message