You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by lchang87 <lc...@163.com> on 2011/03/06 14:13:28 UTC

About using a DataObject as a webservice return type

Hi: 
I am using the sca to build a online store project. In the project, I use das and sdo. Now I run into some problems. There are  two  composite files, client and server:
client.composite:
  <sca:component name="Login">
      <sca:implementation.java class="cst.zju.purchase.user.login.impl.LoginServiceImpl"/>
      <sca:service name="LoginService"/>
      <sca:reference name="userDataService">
              <sca:binding.ws uri="http://china-2ab29e33a:8081/purchase/userDBOP"/>
      </sca:reference>
  </sca:component>
the implementation class is :
@Service(interfaces={LoginService.class})
@Scope("Composite")
public class LoginServiceImpl implements LoginService{
private UserDataService userDataService;
@Reference
public void setUserDataService(UserDataService userDataService) {
this.userDataService = userDataService;
}
public boolean login(String username, String password) {
DataObject user = userDataService.getUser(username);
System.out.println("username= " + user.getString("password"));
if(username.equals(user.getString("password"))){
return true;
}else{
return false;
}
}
}


server.composite:
<sca:component name="DataOperationComponent">
    <sca:implementation.java class=""/>
    <sca:service name="UserDataService">
      <sca:interface.java interface="cst.zju.purchase.das.UserDataService"/>
    </sca:service>  
</sca:component>
<sca:service name="UserDBService" promote="DataOperationComponent/UserDataService">
    <sca:binding.ws uri="http://localhost:8081/purchase/userDBOP"/>
</sca:service>


the implementation class is :
@Service(interfaces={UserDataService .class})
@Scope("Composite")
public class DataServiceImpl implements UserDataService {
public DataObject getUser(String username) {
Command read = das.getCommand("get customer by username");
read.setParameter(1, username);
DataObject root = read.executeQuery();
List list = root.getList("customer");
return (DataObject) list.get(0);
}
}


when I invoke the method login(username,password), I get some exceptions:
Exception in thread "main" org.apache.tuscany.sca.databinding.TransformationException: org.apache.tuscany.sca.databinding.TransformationException: java.lang.RuntimeException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'http:///org.apache.tuscany.das.rdb/das' not found.
at org.apache.tuscany.sca.core.databinding.transformers.Output2OutputTransformer.transform(Output2OutputTransformer.java:253)
at org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:113)
at org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediateOutput(MediatorImpl.java:405)
at org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:89)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:349)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193)
at $Proxy8.getUser(Unknown Source)
at cst.zju.purchase.user.login.impl.LoginServiceImpl.login(LoginServiceImpl.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:156)
at org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:60)
at org.apache.tuscany.sca.binding.sca.impl.SCABindingInvoker.invoke(SCABindingInvoker.java:61)
at org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:60)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:349)
at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193)
at $Proxy7.login(Unknown Source)
at cst.zju.purchase.user.test.Test.main(Test.java:17)


Perhaps the client does not recognize the DataObject type. If I want to invoke a remote method with a DataObject(SDO) return type using webservice binding, how should I do?


chang.

Re: About using a DataObject as a webservice return type

Posted by Simon Laws <si...@googlemail.com>.
2011/3/6 lchang87 <lc...@163.com>:
> Hi:
> I am using the sca to build a online store project. In the project, I use
> das and sdo. Now I run into some problems. There are  two  composite files,
> client and server:
> client.composite:
>   <sca:component name="Login">
>       <sca:implementation.java
> class="cst.zju.purchase.user.login.impl.LoginServiceImpl"/>
>       <sca:service name="LoginService"/>
>       <sca:reference name="userDataService">
>               <sca:binding.ws
> uri="http://china-2ab29e33a:8081/purchase/userDBOP"/>
>       </sca:reference>
>   </sca:component>
> the implementation class is :
> @Service(interfaces={LoginService.class})
> @Scope("Composite")
> public class LoginServiceImpl imple ments LoginService{
> private UserDataService userDataService;
> @Reference
> public void setUserDataService(UserDataService userDataService) {
> this.userDataService = userDataService;
> }
> public boolean login(String username, String password) {
> DataObject user = userDataService.getUser(username);
> System.out.println("username= " + user.getString("passwo rd"));
> if(username.equals(user.getString("password"))){
> return true;
> }else{
> return false;
> }
> }
> }
> server.composite:
> <sca:component name="DataOperationComponent">
>     <sca:implementation.java class=""/>
>     <sca:service name="UserDataService">
>       <sca:interface.java interface="cst.zju.purchase.das.UserDataService"/>
>     </sca:service>
> </sca:co mponent>
> <sca:service name="UserDBService"
> promote="DataOperationComponent/UserDataService">
>     <sca:binding.ws uri="http://localhost:8081/purchase/userDBOP"/>
> </sca:service>
> the implementation class is :
> @Service(interfaces={UserDataService .class})
> @Scope("Composite")
> public class DataServiceImpl implements UserDataService {
> public DataObject getUser(String username) {
> Command read = das.getCommand("get customer by username");
> read.setParameter(1, username);
> DataObject root = read.executeQuery();
> List list = root.getList("customer");
> return (DataObject) list.get(0);
> }
> }
> when I invoke the method login(username,password), I get some exceptions:
> Exception in thread "main"
> org.apache.tuscany.sca.databinding.TransformationException:
> org.apache.tuscany.sca.databinding.TransformationException:
> java.lang.RuntimeException:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri
> 'http:///org.apache.tuscany.das.rdb/das' not found.
> at
> org.apache.tuscany.sca.core.databinding.transformers.Output2OutputTransformer.transform(Output2OutputTransformer.java:253)
> at org.apache.tuscany.sca.databinding.impl.MediatorI
> mpl.mediate(MediatorImpl.java:113)
> at
> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediateOutput(MediatorImpl.java:405)
> at
> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:89)
> at
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:349)
> at
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193)
> at $Proxy8.getUser(Unknown Source)
> at cst.zju.purchase.user.login.impl.LoginServiceImpl.login(LoginServiceImp
> l.java:24)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:156)
> at
> org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:60)
> a t
> org.apache.tuscany.sca.binding.sca.impl.SCABindingInvoker.invoke(SCABindingInvoker.java:61)
> at
> org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:60)
> at
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:349)
> at
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:193)
> at $Proxy7.login(Unknown Source)
> at cst.zju.purchase.user.test.Test.main(Test.java:17)
> Perhaps the client does not recognize the DataObject type. If I want to
> invoke a remote method with a DataObject(SDO ) return type using webservice
> binding, how should I do?
> chang.
>
>

Hi Chang

What version of Tuscany are you using? I assume 1.x.

There are a couple of SDO samples in 1.x, e.g. [1], but I can't find
one that uses dynamic SDO and/or DAS. I though we had something in one
of the bank samples but I can't find it. Anyone know of one for
reference?

Looking at the stack dump it looks like the DAS creates the DataObject
in a DAS specific namespace that's, probably not surprisingly,  not
represented in the service interface.

What does you service interface look like?

[1] http://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/samples/helloworld-ws-sdo/

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com