You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Andrea Zoppello <zo...@tiscali.it> on 2008/12/01 09:41:45 UTC

Re: CxfBC Provider Problem!!!

Hi Freeman,

First of all thank you for the response.

Here my comments

1) I'm using servicemix-3.3 with the servicemix-cxf-bc-2008.01, i'll 
open a JIRA with the test case, but i'll open a JIRA for that.

2) Regarding your doubt on my solution probably you're right maybe it's 
not the best one, but *it works* ant it's what it's important at the moment.

Regarding stax, i totally agree on the performance, but this is not the 
first time i have problem
with code that is based on stax to handle xml streams.

BTW i'll find a way to not change the standard interceptor, i'll provide 
my  own interceptor, and i'll change only one or two classes on 
servicemix-bc to use my own interceptor instead of the old one.

3) I know and understand perfect why interceptors are shared, but 
suppose an enviromennt wher you could have 10 or 20 cxf ( mixed ) 
provider and consumer endpoints, and you could have problems in 
interceptors chain.  Believe me.. to find an error here is very 
difficult, instead if you have some data you could use for example in 
log4j to trace in the log file something like:

- Endpoint Identifier - Interceptor -  logmessage, you could speed the 
time to find the problems.

BTW your suggestion on the data contained on the message could be 
useful, but the real problem for me is that at the moment the 
interceptors does not know the enpoint using it.


Freeman Fang ha scritto:
> Btw, what servicemix version you are using?
> Freeman Fang wrote:
>> Hi Andrea,
>> Comment inline
>> Andrea Zoppello wrote:
>>> Hi ron,
>>>
>>> I just sent to freeman, a private email with the two zipped sa ( i 
>>> cannot attach zip files in the mailing list) that i've used to 
>>> reproduce this.
>>>
>> Generally you can create a jira and append your testcase on it, just 
>> easy for track the issue
>>> Now this test case is working with my patches.
>> Although it works, but it's not a good solution since your transform 
>> message from stream into dom which lost the performance.
>> I still think the root cause is some tab (or space) character in the 
>> message.
>> Another guy said he has fixed this issue in Cxf StaxUtils but seems 
>> he didn't contribute the patch to cxf, I will investigate this issue 
>> next week when I get chance.
>>>
>>> BTW It seems to be not only a servicemix problem, but a problem of 
>>> both servicemix and cxf interceptors and the way in which xml 
>>> streams are manipulated.
>>>
>> Use Stax is the way how cxf interceptors process the message to get 
>> higher performance
>>> Andrea
>>>
>>> rgavlin ha scritto:
>>>> Hi Andrea,
>>>>
>>>> Were you able to write a test case that reproduces your problem? I 
>>>> have
>>>> found that the SMX committers are quick to implement patches once 
>>>> they have
>>>> been provided a test case that reproduces the problem.
>>>>
>>>> /Ron
>>>>
>>>> You might consider spending your time writing a test case to 
>>>> reproduce the
>>>> problem
>>>> Andrea Zoppello-2 wrote:
>>>>  
>>>>> Hi Ashwin,
>>>>>
>>>>> Thank you for your help,
>>>>>
>>>>> After *two days* of debugging digging into servicemix-cxf, and cxf 
>>>>> core i've finally discovered where is the problem!!!!
>>>>>
>>>>> CXF is really very difficult to debug because interceptor are used 
>>>>> everywhere and the same interceptors are in some case used both by 
>>>>> consumer and provider endpoint, so when you've situation where 
>>>>> you've more than one cxf endpoint debug is very difficult.
>>>>>
>> For both server and client side, they will both have incoming and 
>> outgoing message, for example, incoming message for server side is a 
>> request, but for client side is response, but for most interceptors, 
>> it's not a big difference that get invoked on server side or client 
>> side, such as StaxInInterceptor, it can be used both on client and 
>> server side to process the incoming message, so reuse interceptors 
>> make sense, right?
>>>>> It could be very useful, in future to add to the interceptor some 
>>>>> feature that can help to get
>>>>> debu ginformation on the context in which they're executed ( 
>>>>> they're invoked by provider, by consumer endpoint, by other 
>>>>> endpoints...... )
>> We do have it already,
>> Boolean requestor = (Boolean)message.get("org.apache.cxf.client");
>> I think this is what you want.
>>
>>>>>
>>>>> Is seems the problem is in the *Interceptor Chain*, when the 
>>>>> message is processed by CXFMessageObserver, when the soap response 
>>>>> arrive, i've found the following interceptors are called.
>>>>>
>>>>> 1)AttachmentInInterceptor
>>>>> 2)StaxInInterceptor
>>>>> 3)ReadHeadersInterceptor
>>>>> 4)MustUnderstandInterceptor
>>>>> 5)JbiInWsdl1Interceptor
>>>>>
>>>>> *When the soap message arrive to the first interceptor is well 
>>>>> formed and it's there but when the same message arrive in the last 
>>>>> interceptor it seems that the XMLStreamReader inside the message 
>>>>> is corrupted, and for this reason we've the exception above*
>>>>>
>>>>> I know that maybe i've not found the optimal solution but i've 
>>>>> found a solution to solve al problems caused by code tha 
>>>>> manipulates xml streams in interceptors.
>>>>>
>>>>> I get it working modifying all the code of the interceptors doing 
>>>>> the following operation in each of the above interceptors ( except 
>>>>> for the last one )  in the handleMessage Method
>>>>>
>>>>> 1) First of all at the beginning of the handle method i parse the 
>>>>> message content using
>>>>> dom4j and i save the message content in a string ( messageXML ):
>>>>>
>>>>>             InputStream in = 
>>>>> (InputStream)message.getContent(InputStream.class);
>>>>>             SAXReader saxReader = new SAXReader();
>>>>>             org.dom4j.Document messageDOM = saxReader.read(in);
>>>>>             String messageXML = messageDOM.asXML();
>>>>> 2) At the end of the handleMessage method, i re-save the message 
>>>>> content
>>>>> as:
>>>>>
>>>>>          message.setContent(InputStream.class, new               
>>>>> ByteArrayInputStream(messageXML.getBytes()));
>>>>>             System.out.println(messageXML);
>>>>>
>>>>> 3) I've modified all interceptors code so it recreate the 
>>>>> XMLStreamReader when it's needed using the input stream in the 
>>>>> message.
>>>>>
>>>>> 4) Finally i've modified the JbiInWsdl1Interceptor to use dom4j in 
>>>>> the getBodyElement method.
>>>>>
>>>>> I know it's a little tricky but now it works for me.
>>>>>
>>>>>
>>>>> Ashwin Karpe ha scritto:
>>>>>  
>>>>>> Hi Andrea,
>>>>>>
>>>>>> The code is available in
>>>>>> src/deployables/bindingcomponents/cxf/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc. 
>>>>>>
>>>>>> The code you are interested in is present in 2 classes
>>>>>>    - CxfBcProvider.java
>>>>>>    - CxfBcProviderMessageObserver.java
>>>>>>
>>>>>> The CXFProvider code deals with pushing out the request via a 
>>>>>> transport
>>>>>> conduit. The response from the Server is processed by
>>>>>> CxfBcProviderMessageObserver.
>>>>>>
>>>>>> The CxfBcProviderMessageObserver.java contains an operation called
>>>>>> onMessage(Message message) is invoked by the NMR when a SOAP 
>>>>>> Response is
>>>>>> received. The message is then mapped into a JBI Exchange at  line 
>>>>>> 142
>>>>>> (see
>>>>>> code fragment below)
>>>>>>
>>>>>>             if (boi.getOperationInfo().isOneWay()) {
>>>>>>                 messageExchange.setStatus(ExchangeStatus.DONE);
>>>>>>             } else if (soapMessage.get("jbiFault") != null
>>>>>>                     && soapMessage.get("jbiFault").equals(true)) {
>>>>>>                 Fault fault = messageExchange.createFault();
>>>>>>                 
>>>>>> fault.setContent(soapMessage.getContent(Source.class));
>>>>>>                 messageExchange.setFault(fault);
>>>>>>             } else if (messageExchange instanceof InOut) {
>>>>>>                 NormalizedMessage msg = 
>>>>>> messageExchange.createMessage();
>>>>>>                 
>>>>>> msg.setContent(soapMessage.getContent(Source.class));
>>>>>>                 if (providerEndpoint.isMtomEnabled()) {
>>>>>>                     toNMSAttachments(msg, soapMessage);
>>>>>>                 }
>>>>>>                 messageExchange.setMessage(msg, "out");
>>>>>>             } else if (messageExchange instanceof InOptionalOut) {
>>>>>>                 if (soapMessage.getContent(Source.class) != null) {
>>>>>>                     NormalizedMessage msg =
>>>>>> messageExchange.createMessage();
>>>>>>                     
>>>>>> msg.setContent(soapMessage.getContent(Source.class));
>>>>>>                     if (providerEndpoint.isMtomEnabled()) {
>>>>>>                         toNMSAttachments(msg, soapMessage);
>>>>>>                     }
>>>>>>                     messageExchange.setMessage(msg, "out");
>>>>>>                 } else {
>>>>>>                     messageExchange.setStatus(ExchangeStatus.DONE);
>>>>>>                 }
>>>>>>             } else {
>>>>>>                 messageExchange.setStatus(ExchangeStatus.DONE);
>>>>>>
>>>>>>             }
>>>>>>
>>>>>> Hope this helps.
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Ashwin...
>>>>>>
>>>>>>
>>>>>> Andrea Zoppello-2 wrote:
>>>>>>      
>>>>>>> Hi Ashwin,
>>>>>>>
>>>>>>> I'm using soap12, and traced with soap monitor it seems the SOAP 
>>>>>>> response is valid ahainst the WSDL.
>>>>>>>
>>>>>>> Please could you point the code where the soap response body is 
>>>>>>> mapped into the normalized message!!!
>>>>>>>
>>>>>>> BTW One of the point that is more difficult when using cxf-bc is 
>>>>>>> that it's very difficult to debug, there's no documentation 
>>>>>>> about the interceptor an the order in which these are called.
>>>>>>>
>>>>>>> For example i've a SA exposing a cxf consumer endpoint then 
>>>>>>> within the flow at some point i've used a cxf-bc-provider as a 
>>>>>>> transformer of a pipeline to call an external webservice.
>>>>>>>
>>>>>>> I've tried to debug, the code but some interceptor are called 
>>>>>>> both by cxf-bc-consumer and provider and it's not easy to 
>>>>>>> understand what happen if something goes wrong.
>>>>>>>
>>>>>>> Andrea
>>>>>>>
>>>>>>> Ashwin Karpe ha scritto:
>>>>>>>          
>>>>>>>> Hi Andrea,
>>>>>>>>
>>>>>>>> There are a number of possibilities here. The CXF-BC Provider is
>>>>>>>> responsible
>>>>>>>> for validating the SOAP response from the endpoint and then 
>>>>>>>> mapping the
>>>>>>>> soap:body into the message exchange as a JBI message/part or raw
>>>>>>>> message.
>>>>>>>> Can you please provide further detail on the settings for CXF-BC
>>>>>>>> provider.
>>>>>>>> Also please specify the SOAP version and WSDL version. This is
>>>>>>>> significant
>>>>>>>> for the mapping to take place correctly. The response payload 
>>>>>>>> also has
>>>>>>>> to
>>>>>>>> be
>>>>>>>> WSDL valid in order for the mapping to happen correctly.
>>>>>>>> It is curious however that a null output is being pushed in the 
>>>>>>>> Message
>>>>>>>> exchange without throwing some form of exception...!!!
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>>
>>>>>>>> Ashwin...
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Andrea Zoppello-2 wrote:
>>>>>>>>                
>>>>>>>>> Hi all,
>>>>>>>>>
>>>>>>>>> I'm repeating some test i made a year ago with servicemix-cxf-bc.
>>>>>>>>>
>>>>>>>>> The cxf-bc-consumer seem s to work quite well, but on the 
>>>>>>>>> other side
>>>>>>>>> i'm having
>>>>>>>>> a lot of problems when using cxf-bc-provider to call an external
>>>>>>>>> webservice.
>>>>>>>>>
>>>>>>>>> I'm using a cxf-bc-provider as a transformer within a pipeline.
>>>>>>>>>
>>>>>>>>> I've setup a tcp-monitor between my cxf-bc-provider and the 
>>>>>>>>> external-webservice
>>>>>>>>> and the soap response from external webservice is right.
>>>>>>>>>
>>>>>>>>> The problem is that cxf-bc-provider is responding with a null 
>>>>>>>>> output message.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Could someone point where is the right point to debug to see 
>>>>>>>>> what goes wrong????
>>>>>>>>> What i want to know is if there are some point where i could 
>>>>>>>>> have in
>>>>>>>>> the log file
>>>>>>>>> the soap-response obtained and where the soap message is 
>>>>>>>>> tranformed
>>>>>>>>> into a normalized message.
>>>>>>>>>
>>>>>>>>> Thx
>>>>>>>>>
>>>>>>>>> Andrea
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                         
>>>>>>>> -----
>>>>>>>> --- Ashwin Karpe, Principal Consultant, PS - Opensource Center of
>>>>>>>> Competence Progress Software Corporation
>>>>>>>> 14 Oak Park Drive
>>>>>>>> Bedford, MA 01730
>>>>>>>> --- +1-972-304-9084 (Office) +1-972-971-1700 (Mobile) ---- 
>>>>>>>> Blog: http://opensourceknowledge.blogspot.com/
>>>>>>>>
>>>>>>>>
>>>>>>>>                   
>>>>>>>             
>>>>>> -----
>>>>>> --- Ashwin Karpe, Principal Consultant, PS - Opensource Center of 
>>>>>> Competence Progress Software Corporation
>>>>>> 14 Oak Park Drive
>>>>>> Bedford, MA 01730
>>>>>> --- +1-972-304-9084 (Office) +1-972-971-1700 (Mobile) ---- Blog: 
>>>>>> http://opensourceknowledge.blogspot.com/
>>>>>>
>>>>>>
>>>>>>         
>>>>>
>>>>>     
>>>>
>>>>   
>>>
>>>
>>
>>
>
>