You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Gary Pinkham <ga...@thepinkhams6.com> on 2007/11/29 19:36:17 UTC

Setting Content Type

Is there a way to control the content type that CXF sends.. I'm having
a heck of a time figuring out how.. Here's the issue.. My CXF client
is sending a content type of "text/xml;charset=utf-8" while my WCF
client (and service) is using "application/soap+xml; charset=utf-8".
This is the configuration of my client:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
	<bean id="client" class="com.foo.aaa.helloworld.IHelloWorld"
factory-bean="clientFactory" factory-method="create" />
	<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
		<property name="serviceClass" value="com.foo.aaa.helloworld.IHelloWorld" />
		<property name="address"
value="http://bar.foo.com:9080/WCFSampleService/Service.svc" />
		<property name="outInterceptors">
			<list>
				<bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
				<ref bean="wss4jOutConfiguration" />
			</list>
		</property>
	</bean>
	<bean id="wss4jOutConfiguration"
class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
		<property name="properties">
			<map>
				<entry key="action" value="UsernameToken Timestamp Signature" />
				<entry key="user" value="ws-client" />
				<entry key="passwordType" value="PasswordDigest" />
				<entry key="signaturePropFile" value="client_sign.properties" />
				<entry key="encryptionPropFile" value="client_sign.properties" />
				<entry>
					<key>
						<value>passwordCallbackRef</value>
					</key>
					<ref bean="passwordCallback" />
				</entry>
			</map>
		</property>
	</bean>
	<bean id="passwordCallback"
class="com.foo.aaa.helloworld.PasswordCallbackHandler" />
</beans>

I tried to add:
	<http:conduit name="*.http-conduit">
		<http:client AllowChunking="false"
ContentType="application/soap+xml; charset=utf-8" />
    </http:conduit>

But it didn't change the request being sent (chunked nor the content
type changed)..   I'm assuming this is not the way to change it..

Any help would be great.  Thanks!
Gary


-- 
The Bargains are Waiting.   Find a Yard Sale at GoYarding.com!!

Re: Setting Content Type

Posted by Glen Mazza <gl...@verizon.net>.
Am Donnerstag, den 29.11.2007, 13:36 -0500 schrieb Gary Pinkham:

> I tried to add:
> 	<http:conduit name="*.http-conduit">
> 		<http:client AllowChunking="false"
> ContentType="application/soap+xml; charset=utf-8" />
>     </http:conduit>
> 
> But it didn't change the request being sent (chunked nor the content
> type changed)..   I'm assuming this is not the way to change it..
> 

Yes, you may be having a syntax issue.  Perhaps Step #8 of my eBay
example would help you (at least with syntax, I haven't sent content
types yet):

http://www.jroller.com/gmazza/entry/using_the_ebay_shopping_api1

HTH,
Glen


> Any help would be great.  Thanks!
> Gary
> 
> 


Re: Setting Content Type

Posted by Gary Pinkham <ga...@thepinkhams6.com>.
That fixed it for me..  No more "invalid Content Type" error...   Now
I need to conquer encryption..  (I think that's why WCF is returning
an http 400...)

Thanks for the help.
Gary

-- 
The Bargains are Waiting.   Find a Yard Sale at GoYarding.com!!


On 11/29/07, Willem Jiang <ni...@iona.com> wrote:
> Hi Gary,
>
> It should work with the CXF 2.0.3.
> If you are using CXF < 2.0.3 , here is a work around way for it in the
> JIRA[1] comment.
>
> [1]http://issues.apache.org/jira/browse/CXF-922
>
> Willem.
>
> Gary Pinkham wrote:
> > Is there a way to control the content type that CXF sends.. I'm having
> > a heck of a time figuring out how.. Here's the issue.. My CXF client
> > is sending a content type of "text/xml;charset=utf-8" while my WCF
> > client (and service) is using "application/soap+xml; charset=utf-8".
> > This is the configuration of my client:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <beans xmlns="http://www.springframework.org/schema/beans"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="
> > http://www.springframework.org/schema/beans
> > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> > http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
> >       <bean id="client" class="com.foo.aaa.helloworld.IHelloWorld"
> > factory-bean="clientFactory" factory-method="create" />
> >       <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
> >               <property name="serviceClass" value="com.foo.aaa.helloworld.IHelloWorld" />
> >               <property name="address"
> > value="http://bar.foo.com:9080/WCFSampleService/Service.svc" />
> >               <property name="outInterceptors">
> >                       <list>
> >                               <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
> >                               <ref bean="wss4jOutConfiguration" />
> >                       </list>
> >               </property>
> >       </bean>
> >       <bean id="wss4jOutConfiguration"
> > class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
> >               <property name="properties">
> >                       <map>
> >                               <entry key="action" value="UsernameToken Timestamp Signature" />
> >                               <entry key="user" value="ws-client" />
> >                               <entry key="passwordType" value="PasswordDigest" />
> >                               <entry key="signaturePropFile" value="client_sign.properties" />
> >                               <entry key="encryptionPropFile" value="client_sign.properties" />
> >                               <entry>
> >                                       <key>
> >                                               <value>passwordCallbackRef</value>
> >                                       </key>
> >                                       <ref bean="passwordCallback" />
> >                               </entry>
> >                       </map>
> >               </property>
> >       </bean>
> >       <bean id="passwordCallback"
> > class="com.foo.aaa.helloworld.PasswordCallbackHandler" />
> > </beans>
> >
> > I tried to add:
> >       <http:conduit name="*.http-conduit">
> >               <http:client AllowChunking="false"
> > ContentType="application/soap+xml; charset=utf-8" />
> >     </http:conduit>
> >
> > But it didn't change the request being sent (chunked nor the content
> > type changed)..   I'm assuming this is not the way to change it..
> >
> > Any help would be great.  Thanks!
> > Gary
> >
> >
> >
>

Re: Setting Content Type

Posted by Willem Jiang <ni...@iona.com>.
Hi Gary,

It should work with the CXF 2.0.3.
If you are using CXF < 2.0.3 , here is a work around way for it in the 
JIRA[1] comment.

[1]http://issues.apache.org/jira/browse/CXF-922

Willem.

Gary Pinkham wrote:
> Is there a way to control the content type that CXF sends.. I'm having
> a heck of a time figuring out how.. Here's the issue.. My CXF client
> is sending a content type of "text/xml;charset=utf-8" while my WCF
> client (and service) is using "application/soap+xml; charset=utf-8".
> This is the configuration of my client:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">
> 	<bean id="client" class="com.foo.aaa.helloworld.IHelloWorld"
> factory-bean="clientFactory" factory-method="create" />
> 	<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
> 		<property name="serviceClass" value="com.foo.aaa.helloworld.IHelloWorld" />
> 		<property name="address"
> value="http://bar.foo.com:9080/WCFSampleService/Service.svc" />
> 		<property name="outInterceptors">
> 			<list>
> 				<bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
> 				<ref bean="wss4jOutConfiguration" />
> 			</list>
> 		</property>
> 	</bean>
> 	<bean id="wss4jOutConfiguration"
> class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
> 		<property name="properties">
> 			<map>
> 				<entry key="action" value="UsernameToken Timestamp Signature" />
> 				<entry key="user" value="ws-client" />
> 				<entry key="passwordType" value="PasswordDigest" />
> 				<entry key="signaturePropFile" value="client_sign.properties" />
> 				<entry key="encryptionPropFile" value="client_sign.properties" />
> 				<entry>
> 					<key>
> 						<value>passwordCallbackRef</value>
> 					</key>
> 					<ref bean="passwordCallback" />
> 				</entry>
> 			</map>
> 		</property>
> 	</bean>
> 	<bean id="passwordCallback"
> class="com.foo.aaa.helloworld.PasswordCallbackHandler" />
> </beans>
>
> I tried to add:
> 	<http:conduit name="*.http-conduit">
> 		<http:client AllowChunking="false"
> ContentType="application/soap+xml; charset=utf-8" />
>     </http:conduit>
>
> But it didn't change the request being sent (chunked nor the content
> type changed)..   I'm assuming this is not the way to change it..
>
> Any help would be great.  Thanks!
> Gary
>
>
>   

Returning arrays with document/literal

Posted by "Silberman, Nathan" <NS...@doubleclick.com>.
Has anybody had any problem returning arrays with document/literal
wrapped? 

I have the following wsdl that consistenly returns an empty response
even though I can see the server side has data to return as elements in
the array

	...

      <element name="getAllUsersResponse">
        <complexType>
          <sequence>
            <element name="getAllUsersReturn" maxOccurs="unbounded"
type="impl:User"/>
          </sequence>
        </complexType>
      </element>

	... 

  <wsdl:message name="getAllUsersResponse">
    <wsdl:part element="impl:getAllUsersResponse" name="parameters"/>
  </wsdl:message>

	...

    <wsdl:operation name="getAllUsers">
      <wsdl:input message="impl:getAllUsersRequest"
name="getAllUsersRequest"/>
      <wsdl:output message="impl:getAllUsersResponse"
name="getAllUsersResponse"/>
      <wsdl:fault message="impl:ApiException" name="ApiException"/>
    </wsdl:operation>

	...

  <wsdl:binding name="UserServiceSoapBinding" type="impl:UserInterface">
    <wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>

    <wsdl:operation name="getAllUsers">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="getAllUsersRequest">
        <wsdlsoap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getAllUsersResponse">
        <wsdlsoap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="ApiException">
        <wsdlsoap:fault name="ApiException" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>

	...