You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Pedro Quintas <pe...@first.pt> on 2009/07/10 16:57:14 UTC
Create a JBI Client
Hi,
I'm trying to make a JBI Client to send messages to the wsdl-first Example that is shipped with the serviceMix 3.2.3.
This is what I have:
package pt.first.hdi.jbi;
import java.io.IOException;
import javax.jbi.JBIException;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessagingException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.servicemix.client.*;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.jbi.jaxp.StringSource;
import org.xml.sax.SAXException;
public class Teste {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("<-- Begin -->");
ServiceMixClient client = getClient("tcp://localhost:61616");
try {
Destination destination = client.createDestination("service:http://localhost:8192/PersonService/");
InOut me = destination.createInOutExchange();
me.getInMessage().setContent(new StringSource(
"<jbi:message xmlns:jbi=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\""
+ " xmlns:msg=\"http://servicemix.apache.org/samples/wsdl-first/types\" "
+ " name=\"Hello\" "
+ " type=\"msg:HelloRequest\" "
+ " version=\"1.0\">"
+ " <jbi:part>"
+ " <msg:GetPerson><msg:personId>world</msg:personId></msg:GetPerson>"
+ " </jbi:part>"
+ "</jbi:message>"));
client.sendSync(me);
System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("<-- End -->");
}
public static ServiceMixClient getClient(String url) {
RemoteServiceMixClient rsmx = new RemoteServiceMixClient(url);
try {
rsmx.init();
rsmx.start();
} catch (JBIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rsmx;
}
}
But I'm getting this error:
javax.jbi.messaging.MessagingException: Could not find route for exchange: InOut[
id: ID:192.168.20.128-12265298b3a-3:0
status: Active
role: provider
service: {http://localhost:8192/PersonService}
in: <?xml version="1.0" encoding="UTF-8"?><jbi:message xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper" xmlns:msg="http://servicemix.apache.org/samples/wsdl-first/types" name="Hello" type="msg:HelloRequest" version="1.0"> <jbi:part> <msg:GetPerson><msg:personId>world</msg:personId></msg:GetPerson> </jbi:part></jbi:message>
] for service: {http://localhost:8192/PersonService} and interface: null
at org.apache.servicemix.jbi.nmr.DefaultBroker.sendExchangePacket(DefaultBroker.java:297)
at org.apache.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java:882)
at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:395)
at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:470)
at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:442)
at org.apache.servicemix.client.DefaultServiceMixClient.sendSync(DefaultServiceMixClient.java:155)
at pt.first.hdi.jbi.Teste.main(Teste.java:41)
Can anyone tell me what I'm doing wrong?
Thanks,
Kintas
RE: Create a JBI Client
Posted by Pedro Quintas <pe...@first.pt>.
Hi Jean-Baptiste,
I try what you said. I go to the xbeam.xml and copy those URI but I'm still getting the same error.
This is the endpoint that I use:
service:http://servicemix.apache.org/samples/wsdl-first/PersonService
And this is the xbean.xml content:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
xmlns:person="http://servicemix.apache.org/samples/wsdl-first">
<http:endpoint service="person:PersonService"
endpoint="soap"
targetService="person:PersonService"
role="consumer"
locationURI="http://0.0.0.0:8192/PersonService/"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
soap="true" />
</beans>
Do you have more hints ?
Thanks,
Pedro Quintas
-----Mensagem original-----
De: Jean-Baptiste Onofré [mailto:jb@nanthrax.net]
Enviada: sábado, 11 de Julho de 2009 21:33
Para: users@servicemix.apache.org
Assunto: Re: Create a JBI Client
Hi Pedro,
I think that the problem is on the destination name. The destination is
ServiceMix internal URIs. The URIs simplify the accessing of endpoints
within the NMR.
If you use:
Destination destination =
client.createDestination("service:http://localhost:8192/PersonService/");
the destination is not correct. If you want to resolve endpoint using
"public" reference, you need to use something like:
DocumentFragment epr =
URIResolver.createWSAEPR("http://localhost:8192/PersonService/?http.soap=true");
ServiceEndpoint se = client.getContext().resolveEndpointReference(epr);
exchange.setEndpoint(se);
send(exchange);
For example, I guess that you have a xbean.xml looking like:
<beans xmlns:demo="http://servicemix.apache.org/demo/">
<http:soap-consumer service="demo:service" endpoint="endpoint"
locationUri="http://localhost:8192/PersonService/"/>
</beans>
In this case, you can get the destination using:
client.createDestination("service:http://servicemix.apache.org/demo/service");
You can get more explanation about SMX URIs management:
http://servicemix.apache.org/uris.html
Regards
JB
Pedro Quintas wrote:
> Hi,
>
> I'm trying to make a JBI Client to send messages to the wsdl-first Example that is shipped with the serviceMix 3.2.3.
> This is what I have:
>
> package pt.first.hdi.jbi;
>
> import java.io.IOException;
>
> import javax.jbi.JBIException;
> import javax.jbi.messaging.InOut;
> import javax.jbi.messaging.MessagingException;
> import javax.xml.parsers.ParserConfigurationException;
> import javax.xml.transform.TransformerException;
>
> import org.apache.servicemix.client.*;
> import org.apache.servicemix.jbi.jaxp.SourceTransformer;
> import org.apache.servicemix.jbi.jaxp.StringSource;
> import org.xml.sax.SAXException;
>
> public class Teste {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> // TODO Auto-generated method stub
> System.out.println("<-- Begin -->");
> ServiceMixClient client = getClient("tcp://localhost:61616");
>
> try {
> Destination destination = client.createDestination("service:http://localhost:8192/PersonService/");
> InOut me = destination.createInOutExchange();
>
> me.getInMessage().setContent(new StringSource(
> "<jbi:message xmlns:jbi=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\""
> + " xmlns:msg=\"http://servicemix.apache.org/samples/wsdl-first/types\" "
> + " name=\"Hello\" "
> + " type=\"msg:HelloRequest\" "
> + " version=\"1.0\">"
> + " <jbi:part>"
> + " <msg:GetPerson><msg:personId>world</msg:personId></msg:GetPerson>"
> + " </jbi:part>"
> + "</jbi:message>"));
>
> client.sendSync(me);
>
> System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
>
> } catch (MessagingException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (TransformerException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (ParserConfigurationException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (SAXException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> System.out.println("<-- End -->");
> }
>
> public static ServiceMixClient getClient(String url) {
>
> RemoteServiceMixClient rsmx = new RemoteServiceMixClient(url);
> try {
> rsmx.init();
> rsmx.start();
> } catch (JBIException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> return rsmx;
> }
> }
>
> But I'm getting this error:
>
> javax.jbi.messaging.MessagingException: Could not find route for exchange: InOut[
> id: ID:192.168.20.128-12265298b3a-3:0
> status: Active
> role: provider
> service: {http://localhost:8192/PersonService}
> in: <?xml version="1.0" encoding="UTF-8"?><jbi:message xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper" xmlns:msg="http://servicemix.apache.org/samples/wsdl-first/types" name="Hello" type="msg:HelloRequest" version="1.0"> <jbi:part> <msg:GetPerson><msg:personId>world</msg:personId></msg:GetPerson> </jbi:part></jbi:message>
> ] for service: {http://localhost:8192/PersonService} and interface: null
> at org.apache.servicemix.jbi.nmr.DefaultBroker.sendExchangePacket(DefaultBroker.java:297)
> at org.apache.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java:882)
> at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:395)
> at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:470)
> at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:442)
> at org.apache.servicemix.client.DefaultServiceMixClient.sendSync(DefaultServiceMixClient.java:155)
> at pt.first.hdi.jbi.Teste.main(Teste.java:41)
>
>
> Can anyone tell me what I'm doing wrong?
>
> Thanks,
> Kintas
>
--
Jean-Baptiste Onofré
---------------------------------
HomePage
http://www.nanthrax.net
---------------------------------
Contacts
jbonofre@apache.org
jb@nanthrax.net
---------------------------------
OpenSource
BuildProcess/AutoDeploy
http://buildprocess.sourceforge.net
Apache ServiceMix
http://servicemix.apache.org
-----------------------------------
PGP : 17D4F086
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Re: Create a JBI Client
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Pedro,
I think that the problem is on the destination name. The destination is
ServiceMix internal URIs. The URIs simplify the accessing of endpoints
within the NMR.
If you use:
Destination destination =
client.createDestination("service:http://localhost:8192/PersonService/");
the destination is not correct. If you want to resolve endpoint using
"public" reference, you need to use something like:
DocumentFragment epr =
URIResolver.createWSAEPR("http://localhost:8192/PersonService/?http.soap=true");
ServiceEndpoint se = client.getContext().resolveEndpointReference(epr);
exchange.setEndpoint(se);
send(exchange);
For example, I guess that you have a xbean.xml looking like:
<beans xmlns:demo="http://servicemix.apache.org/demo/">
<http:soap-consumer service="demo:service" endpoint="endpoint"
locationUri="http://localhost:8192/PersonService/"/>
</beans>
In this case, you can get the destination using:
client.createDestination("service:http://servicemix.apache.org/demo/service");
You can get more explanation about SMX URIs management:
http://servicemix.apache.org/uris.html
Regards
JB
Pedro Quintas wrote:
> Hi,
>
> I'm trying to make a JBI Client to send messages to the wsdl-first Example that is shipped with the serviceMix 3.2.3.
> This is what I have:
>
> package pt.first.hdi.jbi;
>
> import java.io.IOException;
>
> import javax.jbi.JBIException;
> import javax.jbi.messaging.InOut;
> import javax.jbi.messaging.MessagingException;
> import javax.xml.parsers.ParserConfigurationException;
> import javax.xml.transform.TransformerException;
>
> import org.apache.servicemix.client.*;
> import org.apache.servicemix.jbi.jaxp.SourceTransformer;
> import org.apache.servicemix.jbi.jaxp.StringSource;
> import org.xml.sax.SAXException;
>
> public class Teste {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> // TODO Auto-generated method stub
> System.out.println("<-- Begin -->");
> ServiceMixClient client = getClient("tcp://localhost:61616");
>
> try {
> Destination destination = client.createDestination("service:http://localhost:8192/PersonService/");
> InOut me = destination.createInOutExchange();
>
> me.getInMessage().setContent(new StringSource(
> "<jbi:message xmlns:jbi=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\""
> + " xmlns:msg=\"http://servicemix.apache.org/samples/wsdl-first/types\" "
> + " name=\"Hello\" "
> + " type=\"msg:HelloRequest\" "
> + " version=\"1.0\">"
> + " <jbi:part>"
> + " <msg:GetPerson><msg:personId>world</msg:personId></msg:GetPerson>"
> + " </jbi:part>"
> + "</jbi:message>"));
>
> client.sendSync(me);
>
> System.err.println(new SourceTransformer().contentToString(me.getOutMessage()));
>
> } catch (MessagingException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (TransformerException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (ParserConfigurationException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (SAXException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> System.out.println("<-- End -->");
> }
>
> public static ServiceMixClient getClient(String url) {
>
> RemoteServiceMixClient rsmx = new RemoteServiceMixClient(url);
> try {
> rsmx.init();
> rsmx.start();
> } catch (JBIException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> return rsmx;
> }
> }
>
> But I'm getting this error:
>
> javax.jbi.messaging.MessagingException: Could not find route for exchange: InOut[
> id: ID:192.168.20.128-12265298b3a-3:0
> status: Active
> role: provider
> service: {http://localhost:8192/PersonService}
> in: <?xml version="1.0" encoding="UTF-8"?><jbi:message xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper" xmlns:msg="http://servicemix.apache.org/samples/wsdl-first/types" name="Hello" type="msg:HelloRequest" version="1.0"> <jbi:part> <msg:GetPerson><msg:personId>world</msg:personId></msg:GetPerson> </jbi:part></jbi:message>
> ] for service: {http://localhost:8192/PersonService} and interface: null
> at org.apache.servicemix.jbi.nmr.DefaultBroker.sendExchangePacket(DefaultBroker.java:297)
> at org.apache.servicemix.jbi.container.JBIContainer.sendExchange(JBIContainer.java:882)
> at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:395)
> at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:470)
> at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:442)
> at org.apache.servicemix.client.DefaultServiceMixClient.sendSync(DefaultServiceMixClient.java:155)
> at pt.first.hdi.jbi.Teste.main(Teste.java:41)
>
>
> Can anyone tell me what I'm doing wrong?
>
> Thanks,
> Kintas
>
--
Jean-Baptiste Onofré
---------------------------------
HomePage
http://www.nanthrax.net
---------------------------------
Contacts
jbonofre@apache.org
jb@nanthrax.net
---------------------------------
OpenSource
BuildProcess/AutoDeploy
http://buildprocess.sourceforge.net
Apache ServiceMix
http://servicemix.apache.org
-----------------------------------
PGP : 17D4F086