You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by bluedog <cu...@excite.com> on 2007/11/07 17:49:14 UTC

SOAP Messages and Custom Components

I have written a very simple custom component which extends DefaultComponent
and its endpoint extends ProviderEndpoint.

The custom endpoint code is not rocket science:

  protected void processInOut(MessageExchange exchange, 
                                          NormalizedMessage in, 
                                          NormalizedMessage out) throws
Exception {
    	SourceTransformer sourceTransformer = new SourceTransformer();
    	String inMessage = sourceTransformer.toString(in.getContent());
    	doMetrics(inMessage);
    	out.setContent(new StringSource(inMessage));
  }


The message flow is this:

HTTP Soap Consumer --> Custom Component --> HTTP Soap Provider

What I am seeing is that any SOAP headers passed to the consumer are not
available to the Custom Component (in the in-message or MessageExchange). 
Only if I change the Consumer to be a non-SOAP consumer (e.g. plain XML)
will the SOAP headers appear in the in-message. 

At a fundamental level, is it right to say that the only reason to declare
an HTTP consumer as SOAP is if you want ServiceMix to work with the SOAP
attributes on the message?  Otherwise, the endpoints should be simple XML
and leave the SOAP processing to the destination services?

Again, this may just be a misunderstanding of the use of a SOAP HTTP binding
component, although I can imagine it may be desirable to have the security
SOAP headers used by the flow and retained throughout the flow for use by
external systems?
-- 
View this message in context: http://www.nabble.com/SOAP-Messages-and-Custom-Components-tf4765886s12049.html#a13630991
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: SOAP Messages and Custom Components

Posted by bluedog <cu...@excite.com>.
I think there might be a bug here, but it might also be user error.

I changed the method as below and it worked fine.
The only catch was the exchange.toString() call.
If I remove this, then it fails, no message is delivered to the provider.
If I remove this and turn up the debugging level, which I assume calls
exchange.toString() to generate the log message, it works fine.

Since I cannot rely on debug level logging, I added the explicit call.

Any thoughts on why this would cause any issues?

    protected void processInOut(MessageExchange exchange, NormalizedMessage
in, NormalizedMessage out) throws Exception {

    	exchange.toString();
    	
    	org.apache.servicemix.jbi.util.MessageUtil.transfer(in, out);
        NormalizedMessage inCopy =
org.apache.servicemix.jbi.util.MessageUtil.copy(in);        
        try {
        	SourceTransformer sourceTransformer = new SourceTransformer();
	    	String inMessage = sourceTransformer.toString(inCopy.getContent());
	        doMetrics(inMessage);
        } catch(TransformerException e) {
        	log.error(activated.getEndpointName() + " could not analyze
because: " + e.getMessage());
        }
   	
  }
-- 
View this message in context: http://www.nabble.com/SOAP-Messages-and-Custom-Components-tf4765886s12049.html#a13675836
Sent from the ServiceMix - User mailing list archive at Nabble.com.