使用Mule message-properties-transformer修改Content-Disposition或Content-Type标头

时间:2013-11-06 12:01:45

标签: jax-ws cxf mule

我的出站jaxws-client消息没有设置内容处理。

如果我尝试在出站端点之前添加:

<message-properties-transformer doc:name="Message Properties">
    <add-message-property key="Content-Disposition" value="somevalue"/>
</message-properties-transformer>

<https:outbound-endpoint exchange-pattern="request-response" host="12.34.56.78" port="1234" path="services/SOAP/Tests" doc:name="HTTP" connector-ref="testConnector" responseTimeout="50000" >
    <cxf:jaxws-client 
        clientClass="com.test.Service"
        enableMuleSoapHeaders="true"
        operation="getTest"
        port="Test"
        wsdlLocation="wsdl/test.wsdl">

        <cxf:inInterceptors>
            <spring:bean id="cxfIn" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
        </cxf:inInterceptors> 
        <cxf:outInterceptors>
            <spring:bean id="cxfOut" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
        </cxf:outInterceptors>
    </cxf:jaxws-client>
</https:outbound-endpoint>

Content-Disposition未添加到邮件中。但是,当我在名称中添加一个字符时,例如-Content-Disposition代替Content-Disposition,添加了值:

DEBUG 2013-11-06 12:54:53,286 [[muletest].header.stage1.02] httpclient.wire.header: >> "-Content-Disposition: somevalue[\r][\n]"

原始邮件中已存在的Content-Type标题也是如此。我也无法使用<delete-message-property>将其删除。它们是否以某种方式受到保护而不受修改?

如何添加或修改这些标题?

2 个答案:

答案 0 :(得分:0)

试一试。 删除消息属性转换器。

       <set-property propertyName="Content-Type" value="text/xml" />

<https:outbound-endpoint exchange-pattern="request-response" host="12.34.56.78" port="1234" path="services/SOAP/Tests" doc:name="HTTP" connector-ref="testConnector" responseTimeout="50000" >
    <set-property propertyName="Content-Disposition" value="somevalue"></set-property>
    <cxf:jaxws-client 
        clientClass="com.test.Service"
        enableMuleSoapHeaders="true"
        operation="getTest"
        port="Test"
        wsdlLocation="wsdl/test.wsdl">
                    <cxf:inInterceptors>
            <spring:bean id="cxfIn" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
        </cxf:inInterceptors> 
        <cxf:outInterceptors>
            <spring:bean id="cxfOut" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
        </cxf:outInterceptors>
    </cxf:jaxws-client>
</https:outbound-endpoint>

希望这有帮助。

答案 1 :(得分:0)

https:outbound-endpoint

之前使用此权限
   <set-property propertyName="contentType" value="text/html" /> <!-- Set it to whatever you'd want -->

修改

试试这个:

 <http:outbound-endpoint ref="serverEndpoint" contentType="application/x-download">
            <properties>
                <spring:entry key="Content-Disposition" value="attachment; filename=foo.zip"/>
                <spring:entry key="Content-Type" value="application/x-download"/>
            </properties>
        </http:outbound-endpoint>

Reference