You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by larjohn <la...@gmail.com> on 2009/01/21 18:20:04 UTC
CXF-BC response
Using the wsdl-cxf example I added a camel routing SU, and added a consumer
endpoint to the cxf-bc SU, to send the route it through the camel SU. It
works fine, as the response is logged they way I defined to be. But the
response is no longer shown in the client.html window, where I get only the
HTTP OK 200 response without the message. What should I do to keep getting
the response in the client.html and the camel log component as well?
--
View this message in context: http://www.nabble.com/CXF-BC-response-tp21587850p21587850.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: CXF-BC response
Posted by larjohn <la...@gmail.com>.
I finally imported the second Service interface into the first and now
everything is working fine!
It's been about a week of all-day-long servicemixing, so I am very happy!
Thanks Freeman!!! :jumping:
larjohn wrote:
>
>
> What I am getting now is a "cannot find wsdl:binding operation info for
> getSecond method".
>
> I think it has to do with me reimplementing the Second interface in the
> first service package. Should I provide the interface by just the wsdl,
> and is this possible?
>
> Thank you.
>
>
>
>
> larjohn wrote:
>>
>>
>> and the corresponding xbean :
>>
>> <beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
>> xmlns:second="http://servicemix.apache.org/samples/wsdl_first">
>>
>>
>> <bean class="org.apache.servicemix.samples.wsdl_first.PersonImpl">
>> <property name="second">
>> <cxfse:proxy service="second:SecondService"
>> type="org.apache.servicemix.samples.wsdl_first.Second" />
>> </property>
>> </bean>
>>
>>
>> <cxfse:endpoint>
>> <cxfse:pojo>
>> <bean
>> class="org.apache.servicemix.samples.wsdl_first.PersonImpl" />
>> </cxfse:pojo>
>> </cxfse:endpoint>
>>
>> </beans>
>>
>
>
--
View this message in context: http://www.nabble.com/CXF-BC-response-tp21587850p21632961.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: CXF-BC response
Posted by larjohn <la...@gmail.com>.
I realised my mistake in the beans file. I have now only one bean and the
xbean file looks like this:
<beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
xmlns:second="http://servicemix.apache.org/samples/wsdl_first">
<cxfse:endpoint>
<cxfse:pojo>
<bean
class="org.apache.servicemix.samples.wsdl_first.PersonImpl">
<property name="second">
<cxfse:proxy context="#context"
service="http://servicemix.apache.org/samples/wsdl_first/SecondService"
type="org.apache.servicemix.samples.wsdl_first.Second" />
</property>
</bean>
</cxfse:pojo>
</cxfse:endpoint>
</beans>
What I am getting now is a "cannot find wsdl:binding operation info for
getSecond method".
I think it has to do with me reimplementing the Second interface in the
first service package. Should I provide the interface by just the wsdl, and
is this possible?
Thank you.
larjohn wrote:
>
>
> and the corresponding xbean :
>
> <beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
> xmlns:second="http://servicemix.apache.org/samples/wsdl_first">
>
>
> <bean class="org.apache.servicemix.samples.wsdl_first.PersonImpl">
> <property name="second">
> <cxfse:proxy service="second:SecondService"
> type="org.apache.servicemix.samples.wsdl_first.Second" />
> </property>
> </bean>
>
>
> <cxfse:endpoint>
> <cxfse:pojo>
> <bean
> class="org.apache.servicemix.samples.wsdl_first.PersonImpl" />
> </cxfse:pojo>
> </cxfse:endpoint>
>
> </beans>
>
--
View this message in context: http://www.nabble.com/CXF-BC-response-tp21587850p21626546.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: CXF-BC response
Posted by larjohn <la...@gmail.com>.
Thank you.
I am facing a problem with the property and the bean. In the first service
Implemantation class I have created a property. The PersonImpl now looks
like this:
package org.apache.servicemix.samples.wsdl_first;
import javax.jws.WebService;
import javax.xml.ws.Holder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.api.ServiceMixClient;
import org.apache.servicemix.samples.wsdl_first.types.GetPerson;
import org.apache.servicemix.samples.wsdl_first.types.GetPersonResponse;
@WebService(serviceName = "PersonService", targetNamespace =
"http://servicemix.apache.org/samples/wsdl_first", endpointInterface =
"org.apache.servicemix.samples.wsdl_first.Person")
public class PersonImpl implements Person {
private static final Log log = LogFactory.getLog(PersonImpl.class);
protected ServiceMixClient client;
public void getPerson(Holder<String> personId, Holder<String> ssn,
Holder<String> name)
throws UnknownPersonFault {
if (personId.value == null || personId.value.length() == 0) {
org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault fault =
new org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault();
fault.setPersonId(personId.value);
throw new UnknownPersonFault(null, fault);
}
log.info("############################");
SendSomething();
log.info("Hello there!");
name.value = "Larry";
ssn.value = "000-000-0000";
}
private void SendSomething() {
if(second==null)log.fatal("XXXXX!!null!!XXXXXXXXXXXXXXX");
log.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
log.info(second.getSecond("LL"));
}
Second second;
public void setSecond(Second second) {
log.fatal("XXXXX!!setter!!XXXXXXXXXXXXXXX");
this.second = second;
if(second==null)log.fatal("XXXXX!!setter is
nulling!!XXXXXXXXXXXXXXX");
if(this.second==null)log.fatal("XXXXX!!setter is nulling and
hiding!!XXXXXXXXXXXXXXX");
log.info(second.getSecond("aaa"));
}
public Second getSecond() {
return second;
}
}
and the corresponding xbean :
<beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
xmlns:second="http://servicemix.apache.org/samples/wsdl_first">
<bean class="org.apache.servicemix.samples.wsdl_first.PersonImpl">
<property name="second">
<cxfse:proxy service="second:SecondService"
type="org.apache.servicemix.samples.wsdl_first.Second" />
</property>
</bean>
<cxfse:endpoint>
<cxfse:pojo>
<bean class="org.apache.servicemix.samples.wsdl_first.PersonImpl"
/>
</cxfse:pojo>
</cxfse:endpoint>
</beans>
I didn't import the type from the package, I just created it again using a
new interface also named Second in the package. As service units compile
seperately, no compile error came up. But in runtime could it be harmful?
My problem is that when the service is deployed the second setter is being
called and I can see that the field is gets a not-null value assigned. But,
when the SendSomething method is called, the field second is null! When does
this happen and why?
--
View this message in context: http://www.nabble.com/CXF-BC-response-tp21587850p21624552.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: CXF-BC response
Posted by Freeman Fang <fr...@gmail.com>.
larjohn wrote:
> Thank you!
> The example says
>
> <cxfse:endpoint>
> <cxfse:pojo>
> <bean class="org.apache.servicemix.cxfse.GreeterImplForClientProxy">
> <property name="calculator">
> <cxfse:proxy service="calculator:CalculatorService"
> context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
> </property>
> </bean>
> </cxfse:pojo>
> </cxfse:endpoint>
>
> private CalculatorPortType calculator;
>
> public void setCalculator(CalculatorPortType calculator) {
> this.calculator = calculator;
> }
>
> public CalculatorPortType getCalculator() {
> return calculator;
> }
> public void myMethod() {
> int ret = 0;
> try {
>
> ret = getCalculator().add(1, 2);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> ...
> }
>
>
> How CalculatorPortType is known to the package? Should I import the other
> service's package, the wsdl, or what?
>
CalculatorPortType is the proxy (or client stub) of your service2, so
yes, you need import the package include CalculatorPortType.
> Also, in the attribute service (<cxfse:proxy
> service="calculator:CalculatorService" context="#context"
> type="org.apache.cxf.calculator.CalculatorPortType" />), does the calculator
> prefix relate to the property's name in any way? I mean do they have to be
> the same?
>
They are not related, the property name could be anything, and the
prefix actually come from your wsdl where define the CalculatorService
> Sorry, it is obvious that I am not familiar with bean injections...
>
Re: CXF-BC response
Posted by larjohn <la...@gmail.com>.
Thank you!
The example says
<cxfse:endpoint>
<cxfse:pojo>
<bean class="org.apache.servicemix.cxfse.GreeterImplForClientProxy">
<property name="calculator">
<cxfse:proxy service="calculator:CalculatorService"
context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
</property>
</bean>
</cxfse:pojo>
</cxfse:endpoint>
private CalculatorPortType calculator;
public void setCalculator(CalculatorPortType calculator) {
this.calculator = calculator;
}
public CalculatorPortType getCalculator() {
return calculator;
}
public void myMethod() {
int ret = 0;
try {
ret = getCalculator().add(1, 2);
} catch (Exception e) {
e.printStackTrace();
}
...
}
How CalculatorPortType is known to the package? Should I import the other
service's package, the wsdl, or what?
Also, in the attribute service (<cxfse:proxy
service="calculator:CalculatorService" context="#context"
type="org.apache.cxf.calculator.CalculatorPortType" />), does the calculator
prefix relate to the property's name in any way? I mean do they have to be
the same?
Sorry, it is obvious that I am not familiar with bean injections...
--
View this message in context: http://www.nabble.com/CXF-BC-response-tp21587850p21616443.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: CXF-BC response
Posted by Freeman Fang <fr...@gmail.com>.
larjohn wrote:
> I managed to get the response back, but I need your help anyway. Well I have
> the following scenario:
> 1. A user navigates to a web page and sends a request to Service 1 (which is
> exposed to the bus using cxf-se). The request is transfered to the service
> through a cxf-bc SU. The cxf-se based Service1 is described by a wsdl file,
> exactly like the included example.
> The request arrives to Service1 but before it replies 'OK' or return a
> response, it must notify another cxf-se based service, let's say Service 2.
> So while processing the request, Service1 uses a servicemixclient to send a
> normalised message to Service2. Service2 doesn't have a wsdl description. It
> is a straight implementation with an annotated class and an annotated method
> inside it, just like the one that comes by default in the cxf-se archetype.
> No additional cxf-bc is used. Service1 sent the message using sendsync, so
> it waits for a response.
> 3. Service2 responds, after querying a local database. Service1 then
> unblocks and using the Service2 response, makes a response and sends it back
> to the cxf-bc and the user.
>
> I tried to do the above, but I couldn't make it in the servicemixClient
> part.
> Service 1 is like the following:
>
> package org.apache.servicemix.samples.wsdl_first;
>
> import java.io.StringReader;
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import javax.jbi.messaging.InOut;
> import javax.jbi.messaging.MessagingException;
> import javax.jbi.messaging.NormalizedMessage;
> import javax.jws.WebService;
> import javax.naming.InitialContext;
> import javax.xml.namespace.QName;
> import javax.xml.transform.stream.StreamSource;
> import javax.xml.ws.Holder;
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.servicemix.jbi.api.ClientFactory;
> import org.apache.servicemix.jbi.api.ServiceMixClient;
> import org.apache.servicemix.samples.wsdl_first.types.GetPerson;
> import org.apache.servicemix.samples.wsdl_first.types.GetPersonResponse;
> import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
> import org.springframework.context.support.AbstractXmlApplicationContext;
>
> @WebService(serviceName = "PersonService", targetNamespace =
> "http://servicemix.apache.org/samples/wsdl-first", endpointInterface =
> "org.apache.servicemix.samples.wsdl_first.Person")
> public class PersonImpl implements Person {
>
> private static final Log log = LogFactory.getLog(PersonImpl.class);
> protected ServiceMixClient client;
>
> public void getPerson(Holder<String> personId, Holder<String> ssn,
> Holder<String> name)
> throws UnknownPersonFault {
> if (personId.value == null || personId.value.length() == 0) {
>
> org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault fault =
> new org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault();
> fault.setPersonId(personId.value);
> throw new UnknownPersonFault(null, fault);
> }
> try {
> setUp();
> SendSomething();
> } catch (Exception ex) {
> Logger.getLogger(PersonImpl.class.getName()).log(Level.SEVERE,
> "Setup Exception Here!", ex.getMessage());
> }
>
> log.info("Hello there!");
> name.value = "Larry";
> ssn.value = "000-000-0000";
>
> }
> private void SendSomething() {
> try {
> InOut exchange = client.createInOutExchange();
> NormalizedMessage inMessage = exchange.getInMessage();
> inMessage.setProperty("name", "James");
> inMessage.setContent(new StreamSource(new
> StringReader("<hello>world</hello>")));
> // optionally specify the endpoint
> exchange.setService(new
> QName("service:http://servicemix.apache.org/samples/wsdl_first/SecondService"));
> exchange.setOperation(new QName("sayHello"));
> client.sendSync(exchange);
> NormalizedMessage outMessage = exchange.getOutMessage();
> } catch (MessagingException ex) {
> Logger.getLogger(PersonImpl.class.getName()).log(Level.SEVERE,
> "Message Exception here!", ex);
> }
> }
> protected void setUp() throws Exception {
>
>
> ClientFactory factory = (ClientFactory) new
> InitialContext().lookup(ClientFactory.DEFAULT_JNDI_NAME);
> client = factory.createClient();
> }
> }
>
>
> Service2 is :
>
> package org.apache.servicemix.samples.wsdl_first;
>
> import javax.jws.WebMethod;
> import javax.jws.WebService;
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
>
> @WebService(serviceName = "SecondService", targetNamespace =
> "http://servicemix.apache.org/samples/wsdl_first")
> public class ExampleService {
> private static final Log log = LogFactory.getLog(ExampleService.class);
> @WebMethod
> public String sayHello() {
>
> log.info("------------------LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL!!!!!----------------");
> return "Hello ";
> }
> }
>
> When I send a message to Service1 it doesn't fail, but I don't know how to
> invoke the specific sayHello method of Service2, with parameters and take
> back the result. What should I enter in the exchange var?
>
>
If you want to invoke service2 from service1, you can inject the proxy
of service2 into service1, take a look at [1], the Proxies part.
It's so easy that you only need invoke a java object and get rid of the
servicemix client api as well as marshall/unmarshal message yourself.
[1]http://servicemix.apache.org/servicemix-cxf-se.html
> Also, I have a camel component that takes the request from the cxf-bc and
> routes it to the cxf-se (I know it is not needed, just testing!). How can I
> send the same request to Service2? If it responds somehow (by the way,
> how?), which response will be returned to cxf-bc Service1 or Service2 ?
>
> Finally, if I want to return the response in a html page, using eg a
> transform, how can I do this, and how to define the webpage? Do I need
> another SU?
>
> Thanks in advance!
>
> Larry Johnson
>
>
> Freeman Fang wrote:
>
>> Hi,
>>
>> Couldn't tell you more unless you post more details about your
>> workflow, your configuration.
>>
>> Regards
>> Freeman
>>
>>
>>
>>
>>
>>
>
>
Re: CXF-BC response
Posted by larjohn <la...@gmail.com>.
I managed to get the response back, but I need your help anyway. Well I have
the following scenario:
1. A user navigates to a web page and sends a request to Service 1 (which is
exposed to the bus using cxf-se). The request is transfered to the service
through a cxf-bc SU. The cxf-se based Service1 is described by a wsdl file,
exactly like the included example.
The request arrives to Service1 but before it replies 'OK' or return a
response, it must notify another cxf-se based service, let's say Service 2.
So while processing the request, Service1 uses a servicemixclient to send a
normalised message to Service2. Service2 doesn't have a wsdl description. It
is a straight implementation with an annotated class and an annotated method
inside it, just like the one that comes by default in the cxf-se archetype.
No additional cxf-bc is used. Service1 sent the message using sendsync, so
it waits for a response.
3. Service2 responds, after querying a local database. Service1 then
unblocks and using the Service2 response, makes a response and sends it back
to the cxf-bc and the user.
I tried to do the above, but I couldn't make it in the servicemixClient
part.
Service 1 is like the following:
package org.apache.servicemix.samples.wsdl_first;
import java.io.StringReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.jws.WebService;
import javax.naming.InitialContext;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Holder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.api.ClientFactory;
import org.apache.servicemix.jbi.api.ServiceMixClient;
import org.apache.servicemix.samples.wsdl_first.types.GetPerson;
import org.apache.servicemix.samples.wsdl_first.types.GetPersonResponse;
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.context.support.AbstractXmlApplicationContext;
@WebService(serviceName = "PersonService", targetNamespace =
"http://servicemix.apache.org/samples/wsdl-first", endpointInterface =
"org.apache.servicemix.samples.wsdl_first.Person")
public class PersonImpl implements Person {
private static final Log log = LogFactory.getLog(PersonImpl.class);
protected ServiceMixClient client;
public void getPerson(Holder<String> personId, Holder<String> ssn,
Holder<String> name)
throws UnknownPersonFault {
if (personId.value == null || personId.value.length() == 0) {
org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault fault =
new org.apache.servicemix.samples.wsdl_first.types.UnknownPersonFault();
fault.setPersonId(personId.value);
throw new UnknownPersonFault(null, fault);
}
try {
setUp();
SendSomething();
} catch (Exception ex) {
Logger.getLogger(PersonImpl.class.getName()).log(Level.SEVERE,
"Setup Exception Here!", ex.getMessage());
}
log.info("Hello there!");
name.value = "Larry";
ssn.value = "000-000-0000";
}
private void SendSomething() {
try {
InOut exchange = client.createInOutExchange();
NormalizedMessage inMessage = exchange.getInMessage();
inMessage.setProperty("name", "James");
inMessage.setContent(new StreamSource(new
StringReader("<hello>world</hello>")));
// optionally specify the endpoint
exchange.setService(new
QName("service:http://servicemix.apache.org/samples/wsdl_first/SecondService"));
exchange.setOperation(new QName("sayHello"));
client.sendSync(exchange);
NormalizedMessage outMessage = exchange.getOutMessage();
} catch (MessagingException ex) {
Logger.getLogger(PersonImpl.class.getName()).log(Level.SEVERE,
"Message Exception here!", ex);
}
}
protected void setUp() throws Exception {
ClientFactory factory = (ClientFactory) new
InitialContext().lookup(ClientFactory.DEFAULT_JNDI_NAME);
client = factory.createClient();
}
}
Service2 is :
package org.apache.servicemix.samples.wsdl_first;
import javax.jws.WebMethod;
import javax.jws.WebService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@WebService(serviceName = "SecondService", targetNamespace =
"http://servicemix.apache.org/samples/wsdl_first")
public class ExampleService {
private static final Log log = LogFactory.getLog(ExampleService.class);
@WebMethod
public String sayHello() {
log.info("------------------LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL!!!!!----------------");
return "Hello ";
}
}
When I send a message to Service1 it doesn't fail, but I don't know how to
invoke the specific sayHello method of Service2, with parameters and take
back the result. What should I enter in the exchange var?
Also, I have a camel component that takes the request from the cxf-bc and
routes it to the cxf-se (I know it is not needed, just testing!). How can I
send the same request to Service2? If it responds somehow (by the way,
how?), which response will be returned to cxf-bc Service1 or Service2 ?
Finally, if I want to return the response in a html page, using eg a
transform, how can I do this, and how to define the webpage? Do I need
another SU?
Thanks in advance!
Larry Johnson
Freeman Fang wrote:
>
> Hi,
>
> Couldn't tell you more unless you post more details about your
> workflow, your configuration.
>
> Regards
> Freeman
>
>
>
>
>
--
View this message in context: http://www.nabble.com/CXF-BC-response-tp21587850p21601039.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: CXF-BC response
Posted by Freeman Fang <fr...@gmail.com>.
Hi,
Couldn't tell you more unless you post more details about your
workflow, your configuration.
Regards
Freeman
larjohn wrote:
> I m not sure it is a response in the log! Maybe it is the request transformed
> someway. Could anybody help?
>
> larjohn wrote:
>
>> Using the wsdl-cxf example I added a camel routing SU, and added a
>> consumer endpoint to the cxf-bc SU, to send the route it through the camel
>> SU. It works fine, as the response is logged they way I defined to be. But
>> the response is no longer shown in the client.html window, where I get
>> only the HTTP OK 200 response without the message. What should I do to
>> keep getting the response in the client.html and the camel log component
>> as well?
>>
>>
>
>
Re: CXF-BC response
Posted by larjohn <la...@gmail.com>.
I m not sure it is a response in the log! Maybe it is the request transformed
someway. Could anybody help?
larjohn wrote:
>
> Using the wsdl-cxf example I added a camel routing SU, and added a
> consumer endpoint to the cxf-bc SU, to send the route it through the camel
> SU. It works fine, as the response is logged they way I defined to be. But
> the response is no longer shown in the client.html window, where I get
> only the HTTP OK 200 response without the message. What should I do to
> keep getting the response in the client.html and the camel log component
> as well?
>
--
View this message in context: http://www.nabble.com/CXF-BC-response-tp21587850p21588852.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.