You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by apinke <ap...@gmail.com> on 2006/06/18 09:08:35 UTC

HTTPInvoker usage

I want to use the HTTPInvoker Component to POST /GET data from a servlet.
I didnt find any example and this wiki page :
http://servicemix.goopen.org/site/http.html
does talk about it but does not provide any example..

I tried it as follows but no success...

Heres the part in servicemix.xml :
	<sm:activationSpec componentName="hservice" 	
				   service="foo:hservice"
				   endpoint="hservice">
		  		  <sm:component>
		  		    <bean class="org.apache.servicemix.components.http.HttpInvoker">
		  		     <property name="url"
value="http://localhost:8080/ServiceMixTest/MockServlet"/>
		  		    </bean>
		  		  </sm:component>
  		</sm:activationSpec>
======
Heres how I send some data :

        InOut inout = createInOutExchange(new QName(Constants.MY_NAMESPACE,
"hservice"), null, null);
        inout.setProperty(Constants.PROPERTY_CORRELATIONID, id);
        NormalizedMessage msg = inout.createMessage();
  msg.setProperty("key1","value1");      
  msg.setProperty("key2","value2");      
  inout.setInMessage(msg);
      
        send(inout);

===

None of this is actually working...
Is that the right way to define a HTTPInvoker in the servicemix.xml ?
Can I also pass in the "URL" using : 
inout.setProperty("url","http://localhost:8080/ServiceMixTest/MockServlet");

How do I pass the parameters to the servlet ? I want the "key1" and "key2"
params to be sent to the servlet ( as GET or POST ).

I see the following error in the log :

DEBUG - DeliveryChannelImpl.traceMessageExchange(342) | Sent:
MessageExchange[
  id: ID:PATPC-3976-1150604064812-5:0
  status: Error
  role: provider
  service: {http://servicemix.org/demo/}hservice
  endpoint: hservice
  in: 
  error: Error executing http request
]

Thanks for any suggestions.
Pat
--
View this message in context: http://www.nabble.com/HTTPInvoker-usage-t1805698.html#a4921098
Sent from the ServiceMix - User forum at Nabble.com.


Re: HTTPInvoker usage

Posted by apinke <ap...@gmail.com>.
If you are getting the same execption , then that means the "Content" in your
Message has not been set.
You  can set a "<dummy/>" content and that should solve your problem.

Pat
-- 
View this message in context: http://www.nabble.com/HTTPInvoker-usage-tf1805698.html#a5570079
Sent from the ServiceMix - User forum at Nabble.com.


Re: HTTPInvoker usage

Posted by kcwu <gu...@yahoo.com>.
I am new to SM and I am trying to do the exact same thing as you mentioned. I
want to use the HTTPInvoker Component to POST /GET data from a servlet. I
don't know how to pass the input parameters to the servlet. Have you figured
it out? Would you please show me how to do it?

Many many thanks.

KC
-- 
View this message in context: http://www.nabble.com/HTTPInvoker-usage-tf1805698.html#a5545923
Sent from the ServiceMix - User forum at Nabble.com.


Re: HTTPInvoker usage

Posted by apinke <ap...@gmail.com>.
Figured this one out.
There was an exception in the HTTPInvoker class that was not getting
printed.

java.lang.IllegalArgumentException: The content cannot be null
        at
org.apache.commons.httpclient.methods.StringRequestEntity.<init>(StringRequestEntity.java
:75)
        at
org.apache.servicemix.components.http.HttpClientMarshaler.fromNMS(HttpClientMarshaler.jav
a:109)

Even though the exception is being caught in HTTPInvoker :
line 71: throw new MessagingException("Error executing http request", e);
the error was not getting printed anywhere in the log.

Setting the content in the message fixed the problem.

Thanks
Pat
--
View this message in context: http://www.nabble.com/HTTPInvoker-usage-t1805698.html#a4934760
Sent from the ServiceMix - User forum at Nabble.com.