You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "martin.pelikan" <ma...@profinit.eu> on 2016/11/22 13:48:13 UTC

Camel CXF - wrong Content-Type sent

Hi all,

I am trying to send SOAP request with Content-Type application/soap+xml. I
call SOAPConsumer with correct header, in the middle of the route header is
modified once again (to be sure), but in the end I get HTTP response '415:
Cannot process the message because the content type 'text/xml;
charset=UTF-8' was not the expected type 'application/soap+xml;
charset=utf-8'.' 

Why does CXF changes the content-type and how to force it not to?

///Consumer endpoint
<cxfEndpoint id="SendMessage0"
address="http://${http.host}:${http.port}/SendMessage"
serviceName="tns:SendMessageService" wsdlURL="classpath:/SendMessage.wsdl"
xmlns="http://camel.apache.org/schema/blueprint/cxf"
xmlns:tns="urn:send:message">
		<properties>
			<entry key="dataFormat" value="PAYLOAD"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
		</properties>
		<inInterceptors>
		</inInterceptors>
		<outInterceptors />
		<binding>
			<soap:soapBinding version="1.2"
xmlns:soap="http://cxf.apache.org/blueprint/bindings/soap" />
		</binding>
		<features>
			<bean class="org.apache.cxf.feature.LoggingFeature"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
			<reference id="eventFeature"
interface="org.talend.esb.sam.agent.feature.EventFeature"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
		</features>
</cxfEndpoint>

///Producer endpoint
	<cxfEndpoint id="SendMessage1" serviceName="tns:SendMessageService" 
wsdlURL="classpath:/SendMessage.wsdl" address="${http.client.url}"
xmlns="http://camel.apache.org/schema/blueprint/cxf"
xmlns:tns="urn:send:message">
		<properties>
			<entry key="dataFormat" value="PAYLOAD"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
			<entry key="ws-security.username" value="${ws-security.username}"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
			<entry key="ws-security.password" value="${ws-security.password}"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
		</properties>
		<inInterceptors />
		<features>
			<reference id="eventFeature"
interface="org.talend.esb.sam.agent.feature.EventFeature"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
			<wsa:addressing allowDuplicates="false"
xmlns:wsa="http://cxf.apache.org/ws/addressing" />
			<policies xmlns="http://cxf.apache.org/policy">
				<PolicyReference URI="etc/org.talend.esb.job.token.policy"
xmlns="http://www.w3.org/ns/ws-policy" />
			</policies>
		</features>
	</cxfEndpoint>


<camelContext>
 <route>
   <from uri="SendMessage0">
   <setHeader headerName="Content-Type"><constant>application/soap+xml;
charset=utf-8</constant></setHeader>
   <to uri="SendMessage1">
 




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-CXF-wrong-Content-Type-sent-tp5790368.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel CXF - wrong Content-Type sent

Posted by Aki Yoshida <el...@gmail.com>.
Umm. I don't know if the namespace for the soap binding is right.
According to the online doc
(https://cxf.apache.org/docs/schemas-and-namespaces.html), the
namespace for the soap binding is http://cxf.apache.org/bindings/soap
for both spring and blueprint.


2016-11-22 15:31 GMT+01:00 martin.pelikan <ma...@profinit.eu>:
> Hi Aki, I specified my question. You are correct about using WSDL v1.1. But
> set binding to SOAP1.2 did not help
>                 <binding>
>                         <soap:soapBinding version="1.2"
> xmlns:soap="http://cxf.apache.org/blueprint/bindings/soap" />
>                 </binding>
>
>
>
> Here is stack trace from Karaf:
>
> RouteId              ProcessorId          Processor
> Elapsed (ms)
> [SendMessage_8008] [SendMessage_8008] [http://0.0.0.0:8008/SendMessage
> ] [       590]
> [SendMessage_8008] [to14              ] [SendMessage1
> ] [       590]
>
> Exchange
> ---------------------------------------------------------------------------------------------------------------------------------------
> Exchange[
>         Id                  ID-MPELIKAN02-52343-1479816939214-16-2
>         ExchangePattern     InOut
>         Headers
> {breadcrumbId=ID-MPELIKAN02-52343-1479816939214-16-1,
> CamelCxfMessage={javax.xml.ws.wsdl.port={urn:send:message:v1}c3port,
> org.apache.cxf.service.model.MessageInfo=[MessageInfo INPUT:
> {urn:send:message:v1}SendMessageRequest],
> org.apache.cxf.message.Message.PROTOCOL_HEADERS={accept-encoding=[gzip,deflate],
> connection=[keep-alive], Content-Length=[1172],
> content-type=[application/soap+xml; charset=utf-8], Host=[localhost:8008],
> SOAPAction=["urn:send:message:v1:Request"],
> User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]},
> org.apache.cxf.ws.addressing.MAPAggregator=org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl@5e1865ca,
> org.apache.cxf.interceptor.LoggingMessage.ID=29,
> HTTP_CONTEXT_MATCH_STRATEGY=stem,
> org.apache.cxf.request.url=http://localhost:8008/SendMessage,
> javax.xml.ws.wsdl.interface={urn:send:message:v1}ISendMessage,
> org.talend.esb.sam.agent.message.CustomInfo={},
> org.apache.cxf.request.uri=/SendMessage, HTTP.REQUEST=(POST
> /SendMessage)@331538697 org.eclipse.jetty.server.Request@13c2e109,
> HTTP.CONFIG=null, org.apache.cxf.transport.https.CertConstraints=null,
> Accept=null,
> org.apache.cxf.headers.Header.list=[org.apache.cxf.headers.Header@5f442001,
> org.apache.cxf.binding.soap.SoapHeader@71915283,
> org.apache.cxf.binding.soap.SoapHeader@7bc050b4,
> org.apache.cxf.binding.soap.SoapHeader@ef298e5,
> org.apache.cxf.binding.soap.SoapHeader@5913ea0d,
> org.apache.cxf.binding.soap.SoapHeader@2a6b292b],
> org.apache.cxf.message.Message.PATH_INFO=/SendMessage,
> org.apache.cxf.message.Message.BASE_PATH=/SendMessage,
> org.apache.cxf.message.FaultMode=UNCHECKED_APPLICATION_FAULT,
> org.apache.cxf.interceptor.DocLiteralInInterceptor.DocLiteralInInterceptor.keep-parameters-wrapper=true,
> FlowId=urn:uuid:c631987b-7aff-4e99-a4dc-c4cca467003b,
> schema-validation-enabled=NONE,
> org.apache.cxf.continuations.ContinuationProvider=org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider@615bdbce,
> javax.xml.ws.wsdl.service={urn:send:message:v1}SendMessageService,
> org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@df80db],
> org.apache.cxf.binding.soap.SoapVersion=org.apache.cxf.binding.soap.Soap11@5184aa4f,
> org.apache.cxf.message.Message.ENCODING=UTF-8,
> org.apache.cxf.message.Message.QUERY_STRING=null, HTTP.RESPONSE=HTTP/1.1 200
>
> ,
> org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@55bbe351,
> org.apache.cxf.request.method=POST,
> org.apache.cxf.async.post.response.dispatch=true,
> org.apache.cxf.configuration.security.AuthorizationPolicy=null,
> javax.xml.ws.wsdl.operation={urn:send:message:v1}SendMessage,
> org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false,
> org.apache.cxf.transport.Destination=org.apache.cxf.transport.http_jetty.JettyHTTPDestination@685e5345,
> SOAPAction=urn:send:message:v1:Request,
> javax.xml.ws.wsdl.description=http://0.0.0.0:8008/SendMessage?wsdl,
> org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.DocLiteralInInterceptor.keep-parameters-wrapper=true,
> http.base.path=http://localhost:8008, Content-Type=application/soap+xml;
> charset=utf-8, HTTP.CONTEXT=ServletContext@o.e.j.s.h.ContextHandler{,null}},
> CamelRedelivered=false, CamelRedeliveryCounter=0,
> content-type=application/soap+xml; charset=utf-8, operationName=SendMessage,
> operationNamespace=urn:send:message:v1}
>         BodyType            org.apache.camel.component.cxf.CxfPayload
>         Body
> ]
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-CXF-wrong-Content-Type-sent-tp5790368p5790370.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel CXF - wrong Content-Type sent

Posted by "martin.pelikan" <ma...@profinit.eu>.
Manually editing WSDL and changing <soap:binding> to <soap12:binding> (and
all other elements with prefix 'soap') did the trick. Thanks for pushing me,
Aki.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-CXF-wrong-Content-Type-sent-tp5790368p5790371.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel CXF - wrong Content-Type sent

Posted by "martin.pelikan" <ma...@profinit.eu>.
Hi Aki, I specified my question. You are correct about using WSDL v1.1. But
set binding to SOAP1.2 did not help
		<binding>
			<soap:soapBinding version="1.2"
xmlns:soap="http://cxf.apache.org/blueprint/bindings/soap" />
		</binding>



Here is stack trace from Karaf:

RouteId              ProcessorId          Processor                                                                       
Elapsed (ms)
[SendMessage_8008] [SendMessage_8008] [http://0.0.0.0:8008/SendMessage                                            
] [       590]
[SendMessage_8008] [to14              ] [SendMessage1                                                              
] [       590]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
        Id                  ID-MPELIKAN02-52343-1479816939214-16-2
        ExchangePattern     InOut
        Headers            
{breadcrumbId=ID-MPELIKAN02-52343-1479816939214-16-1,
CamelCxfMessage={javax.xml.ws.wsdl.port={urn:send:message:v1}c3port,
org.apache.cxf.service.model.MessageInfo=[MessageInfo INPUT:
{urn:send:message:v1}SendMessageRequest],
org.apache.cxf.message.Message.PROTOCOL_HEADERS={accept-encoding=[gzip,deflate],
connection=[keep-alive], Content-Length=[1172],
content-type=[application/soap+xml; charset=utf-8], Host=[localhost:8008],
SOAPAction=["urn:send:message:v1:Request"],
User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]},
org.apache.cxf.ws.addressing.MAPAggregator=org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl@5e1865ca,
org.apache.cxf.interceptor.LoggingMessage.ID=29,
HTTP_CONTEXT_MATCH_STRATEGY=stem,
org.apache.cxf.request.url=http://localhost:8008/SendMessage,
javax.xml.ws.wsdl.interface={urn:send:message:v1}ISendMessage,
org.talend.esb.sam.agent.message.CustomInfo={},
org.apache.cxf.request.uri=/SendMessage, HTTP.REQUEST=(POST
/SendMessage)@331538697 org.eclipse.jetty.server.Request@13c2e109,
HTTP.CONFIG=null, org.apache.cxf.transport.https.CertConstraints=null,
Accept=null,
org.apache.cxf.headers.Header.list=[org.apache.cxf.headers.Header@5f442001,
org.apache.cxf.binding.soap.SoapHeader@71915283,
org.apache.cxf.binding.soap.SoapHeader@7bc050b4,
org.apache.cxf.binding.soap.SoapHeader@ef298e5,
org.apache.cxf.binding.soap.SoapHeader@5913ea0d,
org.apache.cxf.binding.soap.SoapHeader@2a6b292b],
org.apache.cxf.message.Message.PATH_INFO=/SendMessage,
org.apache.cxf.message.Message.BASE_PATH=/SendMessage,
org.apache.cxf.message.FaultMode=UNCHECKED_APPLICATION_FAULT,
org.apache.cxf.interceptor.DocLiteralInInterceptor.DocLiteralInInterceptor.keep-parameters-wrapper=true,
FlowId=urn:uuid:c631987b-7aff-4e99-a4dc-c4cca467003b,
schema-validation-enabled=NONE,
org.apache.cxf.continuations.ContinuationProvider=org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider@615bdbce,
javax.xml.ws.wsdl.service={urn:send:message:v1}SendMessageService,
org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@df80db],
org.apache.cxf.binding.soap.SoapVersion=org.apache.cxf.binding.soap.Soap11@5184aa4f,
org.apache.cxf.message.Message.ENCODING=UTF-8,
org.apache.cxf.message.Message.QUERY_STRING=null, HTTP.RESPONSE=HTTP/1.1 200

,
org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@55bbe351,
org.apache.cxf.request.method=POST,
org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.configuration.security.AuthorizationPolicy=null,
javax.xml.ws.wsdl.operation={urn:send:message:v1}SendMessage,
org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false,
org.apache.cxf.transport.Destination=org.apache.cxf.transport.http_jetty.JettyHTTPDestination@685e5345,
SOAPAction=urn:send:message:v1:Request,
javax.xml.ws.wsdl.description=http://0.0.0.0:8008/SendMessage?wsdl,
org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.DocLiteralInInterceptor.keep-parameters-wrapper=true,
http.base.path=http://localhost:8008, Content-Type=application/soap+xml;
charset=utf-8, HTTP.CONTEXT=ServletContext@o.e.j.s.h.ContextHandler{,null}},
CamelRedelivered=false, CamelRedeliveryCounter=0,
content-type=application/soap+xml; charset=utf-8, operationName=SendMessage,
operationNamespace=urn:send:message:v1}
        BodyType            org.apache.camel.component.cxf.CxfPayload
        Body
]



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-CXF-wrong-Content-Type-sent-tp5790368p5790370.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel CXF - wrong Content-Type sent

Posted by Aki Yoshida <el...@gmail.com>.
you can't set the content-type in that way as the content-type is
generated when the soap message is created.
In other words, the content-type is determined by the soap protocol
being used. I suppose your producer has the wsdl that uses SOAP 1.1
that assumes text/xml. To overwrite the soap protocol, please try
setting the soap 1.2 binding in your producer endpoint.
regards, aki

2016-11-22 14:48 GMT+01:00 martin.pelikan <ma...@profinit.eu>:
> Hi all,
>
> I am trying to send SOAP request with Content-Type application/soap+xml. I
> call SOAPConsumer with correct header, in the middle of the route header is
> modified once again (to be sure), but in the end I get HTTP response '415:
> Cannot process the message because the content type 'text/xml;
> charset=UTF-8' was not the expected type 'application/soap+xml;
> charset=utf-8'.'
>
> Why does CXF changes the content-type and how to force it not to?
>
> ///Consumer endpoint
> <cxfEndpoint id="SendMessage0"
> address="http://${http.host}:${http.port}/SendMessage"
> serviceName="tns:SendMessageService" wsdlURL="classpath:/SendMessage.wsdl"
> xmlns="http://camel.apache.org/schema/blueprint/cxf"
> xmlns:tns="urn:send:message">
>                 <properties>
>                         <entry key="dataFormat" value="PAYLOAD"
> xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
>                 </properties>
>                 <inInterceptors>
>                 </inInterceptors>
>                 <outInterceptors />
>                 <binding>
>                         <soap:soapBinding version="1.2"
> xmlns:soap="http://cxf.apache.org/blueprint/bindings/soap" />
>                 </binding>
>                 <features>
>                         <bean class="org.apache.cxf.feature.LoggingFeature"
> xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
>                         <reference id="eventFeature"
> interface="org.talend.esb.sam.agent.feature.EventFeature"
> xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
>                 </features>
> </cxfEndpoint>
>
> ///Producer endpoint
>         <cxfEndpoint id="SendMessage1" serviceName="tns:SendMessageService"
> wsdlURL="classpath:/SendMessage.wsdl" address="${http.client.url}"
> xmlns="http://camel.apache.org/schema/blueprint/cxf"
> xmlns:tns="urn:send:message">
>                 <properties>
>                         <entry key="dataFormat" value="PAYLOAD"
> xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
>                         <entry key="ws-security.username" value="${ws-security.username}"
> xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
>                         <entry key="ws-security.password" value="${ws-security.password}"
> xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
>                 </properties>
>                 <inInterceptors />
>                 <features>
>                         <reference id="eventFeature"
> interface="org.talend.esb.sam.agent.feature.EventFeature"
> xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
>                         <wsa:addressing allowDuplicates="false"
> xmlns:wsa="http://cxf.apache.org/ws/addressing" />
>                         <policies xmlns="http://cxf.apache.org/policy">
>                                 <PolicyReference URI="etc/org.talend.esb.job.token.policy"
> xmlns="http://www.w3.org/ns/ws-policy" />
>                         </policies>
>                 </features>
>         </cxfEndpoint>
>
>
> <camelContext>
>  <route>
>    <from uri="SendMessage0">
>    <setHeader headerName="Content-Type"><constant>application/soap+xml;
> charset=utf-8</constant></setHeader>
>    <to uri="SendMessage1">
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-CXF-wrong-Content-Type-sent-tp5790368.html
> Sent from the Camel - Users mailing list archive at Nabble.com.