You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@synapse.apache.org by Ruwan Linton <ru...@gmail.com> on 2007/08/07 15:24:32 UTC

Re: Sending new message from within synapse

Hi Nick,

First of all sorry for the delay.

I have done a fix to the SynapseEnviorenment.createMessageContext() and
tested the code that you have provided in this thread, it should work now,
but I had to change the EPR since it again points to localhost:8080 which is
again synapse (may be you could create a proxy inside synapse and put that
EPR to test, that is what I have done)

Have a look if you are still interested in this. I will add the Message
Splitting functionality soon with the help of this createMC method. (Please
take the update of the source code svn head and build synapse)

Thanks,
Ruwan.

On 7/12/07, Nick Cook <ni...@ncl.ac.uk> wrote:
>
>
> On 12 Jul 2007, at 10:38, Ruwan Linton wrote:
>
> > Nick,
> >
> > I have created a JIRA for this [1].
> >
> > I will look in to this in detail and fix the issue, so that you can
> > use your
> > old SynEnv.createMessageContext to get this done.
> >
> > Give me some time to clean it up and fix this.
> >
> > Thanks for pointing this.
> >
> > Thanks,
> > Ruwan.
>
>
> - thanks for your help. I'm impressed with the speedy response to
> queries.
>
> Nick
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: Sending new message from within synapse

Posted by Nick Cook <ni...@ncl.ac.uk>.
On 7 Aug 2007, at 14:24, Ruwan Linton wrote:

> Hi Nick,
>
> First of all sorry for the delay.
>
> I have done a fix to the SynapseEnviorenment.createMessageContext()  
> and
> tested the code that you have provided in this thread, it should  
> work now,
> but I had to change the EPR since it again points to localhost:8080  
> which is
> again synapse (may be you could create a proxy inside synapse and  
> put that
> EPR to test, that is what I have done)
>
> Have a look if you are still interested in this. I will add the  
> Message
> Splitting functionality soon with the help of this createMC method.  
> (Please
> take the update of the source code svn head and build synapse)
>
> Thanks,
> Ruwan.
>

- thanks for your efforts. I will take a look next week, I'm on hols  
at the mo :-)

Nick


---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Sending new message from within synapse

Posted by Ruwan Linton <ru...@gmail.com>.
Paul,

I was also thinking of using the same injectMessage through setting a
property on the context and checking that inside injectMessage. But then the
API will add some more restrictions to the user to set that property.

Your suggestion is interesting, but what if the user wants to use the
implicit TO for sending. For example user may need to setTo(new
EPR("http://localhost:9000/service
")) and inject to the proxy so that the send mediator will send to the
specified To.

By doing this user will not be able to use the implicit To for sending isn't
it?

Thanks,
Ruwan

On 8/18/07, Paul Fremantle <pz...@gmail.com> wrote:
>
> Ruwan
>
> I propose that rather than injectToProxy we do:
>
> setTo("proxy:myProxy");
>
> and just use a URL scheme instead.
>
> Thoughts?
>
> Paul
>
> On 8/16/07, Ruwan Linton < ruwan.linton@gmail.com> wrote:
> > Hi Nick,
> >
> > On 8/16/07, Nick Cook <ni...@ncl.ac.uk> wrote:
> > >
> > >
> > > On 16 Aug 2007, at 04:43, Ruwan Linton wrote:
> > >
> > > > Hi Nick,
> > > >
> > > > This behavior is exactly what is expected. If you want to mediate
> > > > the newly
> > > > forked message using another sequence you need to call the
> > > > following, rather
> > > > than injectMessage.
> > >
> > > - OK, thanks for your help, and for further developments. I
> > > understand what is happening now.
> > >
> > > I hadn't realised I could use (new SendMediator()).mediate(newCtx)!
> > >
> > > And I can see the use of being able to inject into the current and
> > > different sequences.
> >
> >
> >
> > Yes, will add this soon. May be we can add a injectToProxy() method as
> well
> > with the proxy name being the parameter to be passed in to the method so
> > that it will inject the message to the relevant proxy service.
> >
> > Thanks,
> > Ruwan
> >
> >
> > Thanks again
> > >
> > > Nick
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: synapse-user-help@ws.apache.org
> > >
> > >
> >
> >
> > --
> > Ruwan Linton
> > http://www.wso2.org - "Oxygenating the Web Services Platform"
> >
>
>
> --
> Paul Fremantle
> Co-Founder and VP of Technical Sales, WSO2
> OASIS WS-RX TC Co-chair
>
> blog: http://pzf.fremantle.org
> paul@wso2.com
>
> "Oxygenating the Web Service Platform", www.wso2.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: Sending new message from within synapse

Posted by Paul Fremantle <pz...@gmail.com>.
Ruwan

I propose that rather than injectToProxy we do:

setTo("proxy:myProxy");

and just use a URL scheme instead.

Thoughts?

Paul

On 8/16/07, Ruwan Linton <ru...@gmail.com> wrote:
> Hi Nick,
>
> On 8/16/07, Nick Cook <ni...@ncl.ac.uk> wrote:
> >
> >
> > On 16 Aug 2007, at 04:43, Ruwan Linton wrote:
> >
> > > Hi Nick,
> > >
> > > This behavior is exactly what is expected. If you want to mediate
> > > the newly
> > > forked message using another sequence you need to call the
> > > following, rather
> > > than injectMessage.
> >
> > - OK, thanks for your help, and for further developments. I
> > understand what is happening now.
> >
> > I hadn't realised I could use (new SendMediator()).mediate(newCtx)!
> >
> > And I can see the use of being able to inject into the current and
> > different sequences.
>
>
>
> Yes, will add this soon. May be we can add a injectToProxy() method as well
> with the proxy name being the parameter to be passed in to the method so
> that it will inject the message to the relevant proxy service.
>
> Thanks,
> Ruwan
>
>
> Thanks again
> >
> > Nick
> >
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: synapse-user-help@ws.apache.org
> >
> >
>
>
> --
> Ruwan Linton
> http://www.wso2.org - "Oxygenating the Web Services Platform"
>


-- 
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair

blog: http://pzf.fremantle.org
paul@wso2.com

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Sending new message from within synapse

Posted by Nick Cook <ni...@ncl.ac.uk>.
On 16 Aug 2007, at 08:22, Ruwan Linton wrote:

>
>
>
> Yes, will add this soon. May be we can add a injectToProxy() method  
> as well
> with the proxy name being the parameter to be passed in to the  
> method so
> that it will inject the message to the relevant proxy service.
>
> Thanks,
> Ruwan

- that would give a nice API.

Thanks

Nick


---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Sending new message from within synapse

Posted by Ruwan Linton <ru...@gmail.com>.
Hi Nick,

On 8/16/07, Nick Cook <ni...@ncl.ac.uk> wrote:
>
>
> On 16 Aug 2007, at 04:43, Ruwan Linton wrote:
>
> > Hi Nick,
> >
> > This behavior is exactly what is expected. If you want to mediate
> > the newly
> > forked message using another sequence you need to call the
> > following, rather
> > than injectMessage.
>
> - OK, thanks for your help, and for further developments. I
> understand what is happening now.
>
> I hadn't realised I could use (new SendMediator()).mediate(newCtx)!
>
> And I can see the use of being able to inject into the current and
> different sequences.



Yes, will add this soon. May be we can add a injectToProxy() method as well
with the proxy name being the parameter to be passed in to the method so
that it will inject the message to the relevant proxy service.

Thanks,
Ruwan


Thanks again
>
> Nick
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: Sending new message from within synapse

Posted by Nick Cook <ni...@ncl.ac.uk>.
On 16 Aug 2007, at 04:43, Ruwan Linton wrote:

> Hi Nick,
>
> This behavior is exactly what is expected. If you want to mediate  
> the newly
> forked message using another sequence you need to call the  
> following, rather
> than injectMessage.

- OK, thanks for your help, and for further developments. I  
understand what is happening now.

I hadn't realised I could use (new SendMediator()).mediate(newCtx)!

And I can see the use of being able to inject into the current and  
different sequences.

Thanks again

Nick







---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Sending new message from within synapse

Posted by Nick Cook <ni...@ncl.ac.uk>.
On 17 Aug 2007, at 16:01, Ruwan Linton wrote:

> Hmmmmm....
>
> Strange... I think after you enable security (that is after signed)  
> it does
> not let you change the message. (this is my wild guess by looking  
> at the
> exception - as usual :D)
>
> At the same time, let me dig in to this in detail and get back to you.
> (Think this will be OK).
>
> This should effect the splitter as well.
>
> Nick, thanks again for the info.
>
> Thanks,
> Ruwan.
>

- thanks.

For now, I have reverted to doing Axis2 client coding in my mediator,  
which works with WS-Security.

Nick


---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Sending new message from within synapse

Posted by Ruwan Linton <ru...@gmail.com>.
Hmmmmm....

Strange... I think after you enable security (that is after signed) it does
not let you change the message. (this is my wild guess by looking at the
exception - as usual :D)

At the same time, let me dig in to this in detail and get back to you.
(Think this will be OK).

This should effect the splitter as well.

Nick, thanks again for the info.

Thanks,
Ruwan.

On 8/17/07, Nick Cook <ni...@ncl.ac.uk> wrote:
>
>
> On 16 Aug 2007, at 04:43, Ruwan Linton wrote:
>
> > Or else you can do the following to get it dispatched to the proxy,
> > rather
> > than injecting the message:
> >
> > (new SendMediator()).mediate(newCtx);
> >
> >
>
> - I now have hit another problem.
>
> The above works until I enable security.
>
> So I use the SendMediator to send the new message through a locally
> defined proxy (at http://localhost:8080/soap/processMessage)
>
> With proxy inSequence defined as:
>
>         <inSequence>
>                 <log level="full"/>
>                 <send>
>                         <endpoint>
>                                 <address uri="
> http://localhost:9100/soap/processMessage"/>
>                         </endpoint>
>                 </send>
>         </inSequence>
>
> The exchange works and, using tcpmon, I see a HTTP 202 from the other
> side.
>
> However, when I enable security as follows:
>
>         <inSequence>
>                 <log level="full"/>
>                 <send>
>                         <endpoint>
>                                 <address uri="
> http://localhost:9100/soap/processMessage">
>                                         <enableSec policy="sec_policy"/>
>                                 </address>
>                         </endpoint>
>                 </send>
>         </inSequence>
>
> I still see the HTTP 202 response in tcpmon but now I get the
> appended exception, which appears to happen before the response gets
> to synapse.
>
> I have tried the above programmatically with an EndpointDefinition
> and using the SendMediator to send directly to http://localhost:9100/
> soap/processMessage from within my mediator but I get the same
> behaviour. It works without security enabled but not when security is
> enabled. Also, it is not a problem with WS-Security signature
> processing etc, that is working fine.
>
> Any ideas what I am doing wrong?
>
>
> Also
>
> Nick
>
> --
> Exception in thread "I/O reactor worker thread 2"
> org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made
> to insert a node where it is not permitted.
>          at org.apache.axiom.om.impl.dom.ParentNode.insertBefore
> (ParentNode.java:195)
>          at org.apache.axiom.om.impl.dom.NodeImpl.appendChild
> (NodeImpl.java:235)
>          at org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl.<init>
> (SOAPEnvelopeImpl.java:65)
>          at
> org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory.getDefaultEnvelope
> (SOAP12Factory.java:222)
>          at
> org.apache.axis2.transport.nhttp.ClientHandler.responseReceived
> (ClientHandler.java:313)
>          at
> org.apache.axis2.transport.nhttp.LoggingNHttpClientHandler.responseRecei
> ved(LoggingNHttpClientHandler.java:96)
>          at
> org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput
> (DefaultNHttpClientConnection.java:94)
>          at
> org.apache.axis2.transport.nhttp.PlainClientIOEventDispatch.inputReady
> (PlainClientIOEventDispatch.java:69)
>          at org.apache.http.impl.nio.reactor.BaseIOReactor.readable
> (BaseIOReactor.java:68)
>          at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent
> (AbstractIOReactor.java:160)
>          at
> org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents
> (AbstractIOReactor.java:145)
>          at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute
> (AbstractIOReactor.java:127)
>          at
> org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor
> $Worker.run(AbstractMultiworkerIOReactor.java:153)
>          at java.lang.Thread.run(Thread.java:613)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: Sending new message from within synapse

Posted by Nick Cook <ni...@ncl.ac.uk>.
On 16 Aug 2007, at 04:43, Ruwan Linton wrote:

> Or else you can do the following to get it dispatched to the proxy,  
> rather
> than injecting the message:
>
> (new SendMediator()).mediate(newCtx);
>
>

- I now have hit another problem.

The above works until I enable security.

So I use the SendMediator to send the new message through a locally  
defined proxy (at http://localhost:8080/soap/processMessage)

With proxy inSequence defined as:

	<inSequence>
		<log level="full"/>
		<send>
			<endpoint>
				<address uri="http://localhost:9100/soap/processMessage"/>
			</endpoint>
		</send>
	</inSequence>

The exchange works and, using tcpmon, I see a HTTP 202 from the other  
side.

However, when I enable security as follows:

	<inSequence>
		<log level="full"/>
		<send>
			<endpoint>
				<address uri="http://localhost:9100/soap/processMessage">
					<enableSec policy="sec_policy"/>
				</address>
			</endpoint>
		</send>
	</inSequence>

I still see the HTTP 202 response in tcpmon but now I get the  
appended exception, which appears to happen before the response gets  
to synapse.

I have tried the above programmatically with an EndpointDefinition  
and using the SendMediator to send directly to http://localhost:9100/ 
soap/processMessage from within my mediator but I get the same  
behaviour. It works without security enabled but not when security is  
enabled. Also, it is not a problem with WS-Security signature  
processing etc, that is working fine.

Any ideas what I am doing wrong?


Also

Nick

--
Exception in thread "I/O reactor worker thread 2"  
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made  
to insert a node where it is not permitted.
         at org.apache.axiom.om.impl.dom.ParentNode.insertBefore 
(ParentNode.java:195)
         at org.apache.axiom.om.impl.dom.NodeImpl.appendChild 
(NodeImpl.java:235)
         at org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl.<init> 
(SOAPEnvelopeImpl.java:65)
         at  
org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory.getDefaultEnvelope 
(SOAP12Factory.java:222)
         at  
org.apache.axis2.transport.nhttp.ClientHandler.responseReceived 
(ClientHandler.java:313)
         at  
org.apache.axis2.transport.nhttp.LoggingNHttpClientHandler.responseRecei 
ved(LoggingNHttpClientHandler.java:96)
         at  
org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput 
(DefaultNHttpClientConnection.java:94)
         at  
org.apache.axis2.transport.nhttp.PlainClientIOEventDispatch.inputReady 
(PlainClientIOEventDispatch.java:69)
         at org.apache.http.impl.nio.reactor.BaseIOReactor.readable 
(BaseIOReactor.java:68)
         at  
org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent 
(AbstractIOReactor.java:160)
         at  
org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents 
(AbstractIOReactor.java:145)
         at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute 
(AbstractIOReactor.java:127)
         at  
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor 
$Worker.run(AbstractMultiworkerIOReactor.java:153)
         at java.lang.Thread.run(Thread.java:613)




---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Sending new message from within synapse

Posted by Ruwan Linton <ru...@gmail.com>.
Hi Nick,

This behavior is exactly what is expected. If you want to mediate the newly
forked message using another sequence you need to call the following, rather
than injectMessage.

newCtx.getConfiguration.getSequence($DEFINED_SEQUENCE_NAME).mediate(newCtx);

Expected behavior of the injectMessage is just to mediate using the main
sequence if the message is not a response to a proxy service. In your case
it is not a response and also by setting the EPR to the proxy EPR, synapse
wont detect it as a proxy service message what you have to do is set the
property

newCtx.setProperty(org.apache.synapse.Constants.PROXY_SERVICE,
$NAME_OF_THE_PROXY);
newCtx.setResponse(true);

Or else you can do the following to get it dispatched to the proxy, rather
than injecting the message:

(new SendMediator()).mediate(newCtx);

BTW: I have almost finished the Splitter and will commit it soon.

PS: But, because of this mail of yours, I feel like it is good to add some
logic to handle your case in the injectMessage method. I will add this soon
at let you know. Thanks for the information and hope you will provide us
some more ideas.

Thanks,
Ruwan.

On 8/16/07, Nick Cook <ni...@ncl.ac.uk> wrote:
>
>
> On 7 Aug 2007, at 14:24, Ruwan Linton wrote:
>
> > Hi Nick,
> >
> > First of all sorry for the delay.
> >
> > I have done a fix to the SynapseEnviorenment.createMessageContext()
> > and
> > tested the code that you have provided in this thread, it should
> > work now,
> > but I had to change the EPR since it again points to localhost:8080
> > which is
> > again synapse (may be you could create a proxy inside synapse and
> > put that
> > EPR to test, that is what I have done)
>
> - I have tried, but I am not sure if I understand.
>
> I have a defined main sequence for synapse and a proxy (named
> "injectProxy").
>
> creating the new message context works and then I do the following:
>
>         newCtx.setTo(new EndpointReference("http://localhost:8080/soap/
> injectProxy"));
>          newCtx.setWSAAction("urn:inject:test");
>          synEnv.injectMessage(newCtx);
>
> but whatever I use for the EPR the main sequence of synapse is used
> for the new message context.
>
> I get the following output in the log:
>
> [HttpServerWorker-1] DEBUG Axis2SynapseEnvironment - Creating Message
> Context
> [HttpServerWorker-1] DEBUG Axis2SynapseEnvironment - Injecting
> MessageContext
> [HttpServerWorker-1] DEBUG Axis2SynapseEnvironment - Using Main
> Sequence for injected message
> ...
> ...
> [HttpServerWorker-1] DEBUG LogMediator - Log mediator :: mediate()
> [HttpServerWorker-1] INFO  LogMediator - To: http://localhost:8080/
> soap/injectProxy, WSAction: urn:inject:test
> ...
>
> Nick
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

Re: Sending new message from within synapse

Posted by Nick Cook <ni...@ncl.ac.uk>.
On 7 Aug 2007, at 14:24, Ruwan Linton wrote:

> Hi Nick,
>
> First of all sorry for the delay.
>
> I have done a fix to the SynapseEnviorenment.createMessageContext()  
> and
> tested the code that you have provided in this thread, it should  
> work now,
> but I had to change the EPR since it again points to localhost:8080  
> which is
> again synapse (may be you could create a proxy inside synapse and  
> put that
> EPR to test, that is what I have done)

- I have tried, but I am not sure if I understand.

I have a defined main sequence for synapse and a proxy (named  
"injectProxy").

creating the new message context works and then I do the following:

	newCtx.setTo(new EndpointReference("http://localhost:8080/soap/ 
injectProxy"));
         newCtx.setWSAAction("urn:inject:test");
         synEnv.injectMessage(newCtx);

but whatever I use for the EPR the main sequence of synapse is used  
for the new message context.

I get the following output in the log:

[HttpServerWorker-1] DEBUG Axis2SynapseEnvironment - Creating Message  
Context
[HttpServerWorker-1] DEBUG Axis2SynapseEnvironment - Injecting  
MessageContext
[HttpServerWorker-1] DEBUG Axis2SynapseEnvironment - Using Main  
Sequence for injected message
...
...
[HttpServerWorker-1] DEBUG LogMediator - Log mediator :: mediate()
[HttpServerWorker-1] INFO  LogMediator - To: http://localhost:8080/ 
soap/injectProxy, WSAction: urn:inject:test
...

Nick


---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org