You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Francisco Quevedo <F....@cs.cardiff.ac.uk> on 2010/10/15 11:58:20 UTC

Problem catching business exceptions with JSON-RPC

  Dear all,

I'm newbie using Tuscany SCA and I'm having problems trying to show in 
the client side a business exception. I've read in the SCA Java Roadmap 
Web 2.0 that it is possible. However, I receive an argument type 
mismatch at  
org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSFaultExceptionMapper.wrapFaultInfo(JAXWSFaultExceptionMapper.java:111).

Let's me explain the scenario of my sample application. I have one 
component called Store which uses SDO to represent the data internally. 
It exhibits a service called CatalogService (using interface java and 
binding.ws wsdlement). Initially I tried to add to this service another 
binding (binding.jsonrpc) to use it from another component implemented 
in widget and using JSON-RPC, but the transformation between SDO object 
and JSON always gave me "Circular Reference Error". So, I created a 
third component which act as a proxy. This new component StoreProxy, 
uses JAXB to internally represent the data, it has a reference to the 
Store/CatalogService binding by binding.ws and it exhibits a new 
services CatalogServiceProxy, which is uses by the widget via JSON-RPC 
binding. In the end the composite looks like that

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<composite targetNamespace="http://example/MyStore"
     xmlns="http://www.osoa.org/xmlns/sca/1.0"
     xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
     name="MyStore" >

<component name="Store">
<implementation.java class="com.mystore.services.StoreImpl"/>
<service name="CatalogService">
<interface.java interface="com.mystore.services.CatalogService" />
<binding.ws 
wsdlElement="http://example/CatalogService#wsdl.port(CatalogService/SOAP)"/> 

</service>
</component>

<component name="StoreProxy">
<implementation.java class="com.mystore.services.StoreProxyImpl"/>
<reference name="proxy" target="Store/CatalogService">
<binding.ws/>
</reference>
<service name="CatalogServiceProxy">
<interface.java interface="com.mystore.services.CatalogServiceProxy"/>
<t:binding.jsonrpc uri="http://localhost:8080/MyStore/CatalogServiceProxy"/>
</service>
</component>

<component name="WebStore">
<t:implementation.widget location="storeWebView.html"/>
<reference name="StoreProxy" target="StoreProxy/CatalogServiceProxy">
<t:binding.jsonrpc/>
</reference>
</component>

</composite>

I generated automatically the SDO and JAXB classes from the WSDL file. 
In the WSDL file it's defined the CatalogService operations, which apart 
form input and output they have a fault part. So, from the Store 
component I catch any exception and wrapped it into 
MyBusinessServiceException and throw it to the StoreProxy. This one, 
catchs the exception without any problem, but I don't do nothing with it 
there, only re-throw to the client (widget component). Is at that moment 
when I receive in the webbrowser the error argument type mismatch at  
org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSFaultExceptionMapper.wrapFaultInfo(JAXWSFaultExceptionMapper.java:111)

I have tried to follow the guidelines from the chapter 5.10 of the book 
Tuscany in action, but even though I still have this issue.
Has anyone an idea of what can be the cause of the problem? Thanks very 
much in advanced.

PS: If you want to test it, I attached the whole application. To run it, 
generate the war with maven, deploy it in Tomcat and enter in the web 
browser "http://localhost:8080/MyStore/"  To show the error click the 
"Get Product" button and then select in the combo box "Product Throw Ex" 
and click "Get".