You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by bebop01 <wo...@pleus.net> on 2006/05/12 16:39:18 UTC
wrong http header
Hello,
I've tried to write a simple example in which a service consumer (SC) calls
a service provider (SP) via servicemix. The SP is a web service running on
jboss. The SC is a java application using JAX-RPC to call the SP.
Without servicemix everything works well. Now I've put servicemix in the
middle using the following servicemix.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:foo="http://servicemix.org/demo/">
<!-- the JBI container -->
<sm:container id="jbi"
useMBeanServer="true"
createMBeanServer="true"
dumpStats="true"
statsInterval="10">
<sm:activationSpecs>
<!-- Create a http server binding on port 8912 and have it forward to the
foo:stockQuote -->
<sm:activationSpec componentName="httpReceiver"
service="foo:httpBinding"
endpoint="httpReceiver"
destinationService="foo:stockQuote">
<sm:component>
<bean class="org.apache.servicemix.components.http.HttpConnector">
<property name="host" value="localhost"/>
<property name="port" value="8912"/>
</bean>
</sm:component>
</sm:activationSpec>
<!-- This just invokes another service -->
<sm:activationSpec componentName="stockQuote"
service="foo:stockQuote"
endpoint="stockQuote">
<sm:component>
<bean class="org.apache.servicemix.components.http.HttpInvoker">
<property name="url"
value="http://10.3.102.192:8080/opsservice/ops"/>
</bean>
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:container>
</beans>
I can see that the message is passed over to jboss. There it throws the
following error:
javax.xml.rpc.JAXRPCException: Cannot create SOAPFault message for:
javax.xml.rpc.soap.SOAPFaultException: javax.xml.soap.SOAPException:
Unsupported content type: text/html; charset=UTF-8
After some investigation with a http monitoring tool I finally figured out
that jboss is right, because servicemix sends a wrong http header which
looks like the following:
<HTTPHeaders>
<script_name />
<server_protocol>HTTP/1.1</server_protocol>
<server_port>8912</server_port>
<user-agent>Java/1.5.0_06</user-agent>
<path_info>/</path_info>
<request_method>POST</request_method>
<remote_addr>127.0.0.1</remote_addr>
<accept>text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*;
q=.2</accept>
<connection>keep-alive</connection>
<content_length>435</content_length>
<server_name>localhost</server_name>
<soapaction>""</soapaction>
<content_type>text/xml; charset=utf-8</content_type>
<remote_host>127.0.0.1</remote_host>
<content-type>text/html; charset=UTF-8</content-type>
<host>10.3.102.192:8080</host>
<content-length>434</content-length>
</HTTPHeaders>
Especially interesting is that it contains two content-type entries. The
second one is wrong. I assume is was added by servicemix.
The original http header which works fine looks like this:
<HTTPHeaders>
<content-type>text/xml; charset=utf-8</content-type>
<accept>text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*;
q=.2</accept>
<content-length>420</content-length>
<soapaction>""</soapaction>
<user-agent>Java/1.5.0_06</user-agent>
<host>10.3.102.192:8080</host>
<connection>keep-alive</connection>
</HTTPHeaders>
Any ideas what to do? Is there a way to configure how the http alteration
works?
I just want to send a SOAP message unmodified from the SC to the SP.
--
View this message in context: http://www.nabble.com/wrong-http-header-t1608026.html#a4359390
Sent from the ServiceMix - User forum at Nabble.com.
Re: wrong http header
Posted by bebop01 <wo...@pleus.net>.
Attached you'll find a full dump of both communications.
Any help would be appreciated.
1. Client -> ServiceMix
Request
-------
POST / HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Length: 435
SOAPAction: ""
User-Agent: Java/1.5.0_06
Host: 10.3.102.193:8082
Connection: keep-alive
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns0="http://org.epo.esb.ops//types"><env:Body><ns0:getPatentData><String_1>Give
me a nice patent via
servicemix!</String_1></ns0:getPatentData></env:Body></env:Envelope>
Response
--------
HTTP/1.1 500 Error+executing+http+request
Content-Type: text/html
Content-Length: 1251
Connection: keep-alive
Server: Jetty(6.0.x)
<html>
<head>
<title>Error 500 Error executing http request</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2><pre>Error executing http request</pre>
<p>RequestURI=/</p>
<p><small> Powered by Jetty:// </small></p>
</body>
</html>
2. ServiceMix -> JBoss
Request
-------
POST /opsservice/ops HTTP/1.1
SCRIPT_NAME:
SERVER_PROTOCOL: HTTP/1.1
SERVER_PORT: 8082
User-Agent: Java/1.5.0_06
PATH_INFO: /
REQUEST_METHOD: POST
REMOTE_ADDR: 127.0.0.1
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
CONTENT_LENGTH: 435
SERVER_NAME: 10.3.102.193
SOAPAction: ""
CONTENT_TYPE: text/xml; charset=utf-8
REMOTE_HOST: 127.0.0.1
Content-Type: text/html; charset=UTF-8
Host: 10.3.102.192:8080
Content-Length: 538
<?xml version="1.0" encoding="UTF-8"?><env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Envelope
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns0="http://org.epo.esb.ops//types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><ns0:getPatentData><String_1>Give
me a nice patent via
servicemix!</String_1></ns0:getPatentData></env:Body></env:Envelope></env:Body></env:Envelope>
Response
--------
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.0.4.CR2 (build: CVSTag=JBoss_4_0_4_CR2
date=200603311500)/Tomcat-5.5
Transfer-Encoding: chunked
Date: Mon, 15 May 2006 10:47:23 GMT
0
--
View this message in context: http://www.nabble.com/wrong-http-header-t1608026.html#a4388926
Sent from the ServiceMix - User forum at Nabble.com.
Re: wrong http header
Posted by Guillaume Nodet <gn...@gmail.com>.
Could you please send the exact full content of the four HTTP
exchanges (in text format, not xml): request / response between client
/ servicemix and between servicemix / jboss ?
Cheers,
Guillaume Nodet
On 5/12/06, bebop01 <wo...@pleus.net> wrote:
>
> Hello,
>
> I've tried to write a simple example in which a service consumer (SC) calls
> a service provider (SP) via servicemix. The SP is a web service running on
> jboss. The SC is a java application using JAX-RPC to call the SP.
> Without servicemix everything works well. Now I've put servicemix in the
> middle using the following servicemix.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
> xmlns:foo="http://servicemix.org/demo/">
>
> <!-- the JBI container -->
> <sm:container id="jbi"
> useMBeanServer="true"
> createMBeanServer="true"
> dumpStats="true"
> statsInterval="10">
>
> <sm:activationSpecs>
>
> <!-- Create a http server binding on port 8912 and have it forward to the
> foo:stockQuote -->
> <sm:activationSpec componentName="httpReceiver"
> service="foo:httpBinding"
> endpoint="httpReceiver"
> destinationService="foo:stockQuote">
> <sm:component>
> <bean class="org.apache.servicemix.components.http.HttpConnector">
> <property name="host" value="localhost"/>
> <property name="port" value="8912"/>
> </bean>
> </sm:component>
> </sm:activationSpec>
>
> <!-- This just invokes another service -->
> <sm:activationSpec componentName="stockQuote"
> service="foo:stockQuote"
> endpoint="stockQuote">
> <sm:component>
> <bean class="org.apache.servicemix.components.http.HttpInvoker">
> <property name="url"
> value="http://10.3.102.192:8080/opsservice/ops"/>
> </bean>
> </sm:component>
> </sm:activationSpec>
>
> </sm:activationSpecs>
> </sm:container>
>
> </beans>
>
> I can see that the message is passed over to jboss. There it throws the
> following error:
>
> javax.xml.rpc.JAXRPCException: Cannot create SOAPFault message for:
> javax.xml.rpc.soap.SOAPFaultException: javax.xml.soap.SOAPException:
> Unsupported content type: text/html; charset=UTF-8
>
> After some investigation with a http monitoring tool I finally figured out
> that jboss is right, because servicemix sends a wrong http header which
> looks like the following:
>
>
> <HTTPHeaders>
> <script_name />
> <server_protocol>HTTP/1.1</server_protocol>
> <server_port>8912</server_port>
> <user-agent>Java/1.5.0_06</user-agent>
> <path_info>/</path_info>
> <request_method>POST</request_method>
> <remote_addr>127.0.0.1</remote_addr>
> <accept>text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*;
> q=.2</accept>
> <connection>keep-alive</connection>
> <content_length>435</content_length>
> <server_name>localhost</server_name>
> <soapaction>""</soapaction>
> <content_type>text/xml; charset=utf-8</content_type>
> <remote_host>127.0.0.1</remote_host>
> <content-type>text/html; charset=UTF-8</content-type>
> <host>10.3.102.192:8080</host>
> <content-length>434</content-length>
> </HTTPHeaders>
>
> Especially interesting is that it contains two content-type entries. The
> second one is wrong. I assume is was added by servicemix.
>
> The original http header which works fine looks like this:
>
> <HTTPHeaders>
> <content-type>text/xml; charset=utf-8</content-type>
> <accept>text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*;
> q=.2</accept>
> <content-length>420</content-length>
> <soapaction>""</soapaction>
> <user-agent>Java/1.5.0_06</user-agent>
> <host>10.3.102.192:8080</host>
> <connection>keep-alive</connection>
> </HTTPHeaders>
>
> Any ideas what to do? Is there a way to configure how the http alteration
> works?
> I just want to send a SOAP message unmodified from the SC to the SP.
> --
> View this message in context: http://www.nabble.com/wrong-http-header-t1608026.html#a4359390
> Sent from the ServiceMix - User forum at Nabble.com.
>
>
--
Cheers,
Guillaume Nodet
Re: wrong http header
Posted by bebop01 <wo...@pleus.net>.
In the class HttpClientMarshaler which is used by HttpInvoker the
content-type and content-header are stripped from the message:
106 protected boolean shouldIncludeHeader(MessageExchange exchange,
String name, Object value) {
107 return value instanceof String &&
108 !"Content-Length".equalsIgnoreCase(name) &&
109 !"Content-Type".equalsIgnoreCase(name);
110 }
After that a content-type of text/html is added to the message:
054 marshaler.fromNMS(method, exchange, in);
055 if (method.getRequestHeader("Content-Type") == null) {
056 method.setRequestHeader("Content-Type", "text/html;
charset=UTF-8");
This seems always to be text/html which would limit the HttpInvoker to text
only. How would it be possible to send jpg or xml (soap) over http?
Correct me if I'm wrong but to me it seems to be a bug.
--
View this message in context: http://www.nabble.com/wrong-http-header-t1608026.html#a4360567
Sent from the ServiceMix - User forum at Nabble.com.