On Thu, Jul 22, 2010 at 5:08 PM, Luciano Resende <[email protected]> wrote:
>
>
> On Mon, Jul 19, 2010 at 12:21 PM, <[email protected]> wrote:
>>
>>
>>
>> Hi,
>>
>> I have ported the jsonp binding from version 2.0 to version 1.4 and have
>> declared the following service:
>>
>>    <component name="ExpLocComponentP">
>>         <implementation.java
>> class="com.service.explocp.ExpLocServiceImpl"/>
>>         <service name="ExpLocService">
>>             <tuscany:binding.jsonp uri="/API/locatorp"/>
>>         </service>
>>     </component>
>>
>>
>> The class has the following method I want to reach:
>>
>> package com.service.explocp;
>> import java.util.ArrayList;
>>
>> public class ExpLocServiceImpl implements ExpLocService {
>> ...
>>    @Override
>>    public void submitQuestion (QuestionDTO qDTO) throws Exception{
>>      try {
>>          qDTO.setSite("EL");
>>          ExpLocCommon.submitQuestion(qDTO) ;
>>      } catch (Throwable _ex) {
>>          LOGGER.error(_ex);
>>      }
>>    }
>>
>> Remembering that the ExpLocService has the annotation:
>>
>> @Remotable
>> public interface ExpLocService {
>>
>>
>> Now, debugging the error presented when executing the URL:
>>
>>
>> http://localhost:8080/eed/API/locatorp/submitQuestion?1=[{"userEmailId":"[email protected]","expertEmailId":"[email protected]","subject":"hello","question":"test
>> test  test  test
>> ","isST":"true","searchKeyword":"","expertiseId":"","site":"test"}]
>>
>> It will go into the code for class JSONPServlet:
>> ...
>> �...@override
>>     public void service(ServletRequest servletRequest, ServletResponse
>> servletResponse) throws ServletException, IOException {
>>
>>         String jsonRequest = getJSONRequest(servletRequest);
>>         Object[] args = jsonToObjects(jsonRequest);
>>         Object response = invokeService(args);  <--- the chain of requests
>> that will return into error starts here
>>         String jsonResponse = getJSONResponse(servletRequest, response);
>>         servletResponse.getOutputStream().println(jsonResponse);
>>    ...
>>
>> later in the class :
>>
>> package
>> org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker
>>
>> Message invoker(Message msg){
>>             ....
>>             Object ret;
>>             if (payload != null && !payload.getClass().isArray()) {
>>                 ret = imethod.invoke(instance, payload);
>>             } else {
>>                 ret = imethod.invoke(instance, (Object[])payload);
>> <--------------------------
>>             }
>>
>>      The imethod has a reference for the method
>>                      submitQuestion which is the method invoked from the
>> URL
>>                                 (at this point the payload variable has
>> the following value in the array index 0 : [{[email protected],
>> [email protected], subject=hello, question=test   test  test
>> test  , isST=true, searchKeyword=, expertiseId=, site=test}] )
>>
>>
>>      and payload has the values passed on the URL but in as Array format
>> instead of the Object questionDTO required by the method.
>>      at this moment the payload comes with the following value:
>>                     [{[email protected],
>> [email protected], subject=hello, question=test   test  test
>> test  , isST=true, searchKeyword=, expertiseId=, site=test}]
>>
>>
>>      So I Think that for some reason in the middle of everything the json
>> object was not converted into the object type required by the method, or it
>> should go into the imethod.invoke(instance, payload).
>>
>>      At the end I got the following error:
>>
>>
>> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>
>> description The server encountered an internal error () that prevented it
>> from fulfilling this request.
>>
>> exception
>>
>> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
>>
>> org.apache.tuscany.sca.binding.jsonp.runtime.JSONPServlet.invokeService(JSONPServlet.java:159)
>>
>> org.apache.tuscany.sca.binding.jsonp.runtime.JSONPServlet.service(JSONPServlet.java:61)
>>
>> org.apache.tuscany.sca.host.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:107)
>>
>> org.apache.tuscany.sca.host.webapp.TuscanyServletFilter.doFilter(TuscanyServletFilter.java:93)
>>
>>
>
> Fabiano,
>
>    Nice to see that you have ported the JSONP binding to 1.x, any chance you
> want to share this with the community so other users of the 1.x code stream
> could also take advantage of the binding ?
>
>    As for your issue, It's hard for us to try to reproduce a problem on a
> ported binding that is not available for the community, as it make things
> harder to guess what the problem is without debugging it.  If you could
> provide a sample unit test where one could reproduce the problem, that would
> be very helpful, this could be done in the 2.x as there is already a JSONP
> binding there, or it could be done after you provide a patch with a version
> of the 1.x ported binding.
>
>
> --
> Luciano Resende
> http://people.apache.org/~lresende
> http://twitter.com/lresende1975
> http://lresende.blogspot.com/
>

To move this along a little I've done a couple of initial things....

1/ I raised JIRA TUSCANY-3635
(https://issues.apache.org/jira/browse/TUSCANY-3635) to record any
progress we make against this issue. It's generally a good idea to
raise a JIRA so that we can tie any code changes and investigations to
the problem being reported.

2/ Added a new test to the 2.x JSONP binding to try passing complex
types. I note from the OP that the target service has an interface
that uses a complex type. It's not clear how complex that type is as
it's not provided so for now I just created a simple bean with a few
fields. Needless to say it doesn't work so the next step is to look at
what's happening.

If your type is simple a quick work around may be to use separate
parameters for the individual fields but I'm assuming that there are
no other issues in the way that the binding has been ported to 1.x

I think the approach we should take is to investigate further on 2.x
and make sure that we are satisfied with our understanding of what's
going one. We can either then fix any issues we see or document the
level of support the binding provided.

If you then need help to apply any fixes to the 1.x port we really
need to get the port into the Tuscany code base, along with suitable
tests, so that we can all see it.

Regards

Simon

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

Reply via email to