将http标头值传递给Web服务使用者 [英] Pass http header value to the web service consumer

查看:90
本文介绍了将http标头值传递给Web服务使用者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将http标头值作为Web服务使用者使用,

I am trying to pass the http header value as the web service consumer,

httpHeader

我将此属性用作Web服务输入,

I use this property as web service input,

    <dw:transform-message doc:name="Transform Message">
    <dw:set-payload><![CDATA[%dw 1.0
    %output application/xml
    %namespace ns0 namespace
    ---
    {
    ns0#GetProject: {
    ns0#projectId: inboundProperties."http.query.params".projectId,
    ns0#upi: inboundProperties.sm_user
    }
    }]]></dw:set-payload>
    </dw:transform-message>

我还尝试将sm_user设置为变量,并尝试如下所示在TransformMessage中访问该变量,但存在相同的错误,

I have also tried setting the sm_user to a variable and trying to access the variable in TransformMessage as below, but the same error,

    <dw:transform-message doc:name="Transform Message">
    <dw:set-payload><![CDATA[%dw 1.0
    %output application/xml
    %namespace ns0 namespace
    ---
    {
    ns0#GetProject: {
    ns0#projectId: inboundProperties."http.query.params".projectId,
    ns0#upi: flowVars.setUPI
    }
    }]]></dw:set-payload>
    </dw:transform-message>

错误:

    Server was unable to read request. ---> There is an error in XML document (3, 32). ---> Input string was not in a correct format.. Message payload is of type: ElementNSImpl

使用SM_USER标头转换XML:

Transform XML using the SM_USER header:

    <?xml version='1.0' encoding='windows-1252'?>
    <ns0:GetProject xmlns:ns0="namespace">
      <ns0:projectId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      <ns0:upi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
    </ns0:GetProject>

流XML:

    <flow name="ProjectEC">
    <dw:transform-message doc:name="Transform Message">
    <dw:set-payload><![CDATA[%dw 1.0
    %output application/xml
    %namespace ns0 namespace
    ---
    {
    ns0#GetProject: {
    ns0#projectId: inboundProperties."http.query.params".projectId ,
    ns0#upi: inboundProperties.SM_USER
    }
    }]]></dw:set-payload>
    </dw:transform-message>
    <ws:consumer config-ref="ECDataService_Consumer" operation="GetProject" doc:name="ECWebServiceConsumer"/>
    <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
    <json:xml-to-json-transformer doc:name="XML to JSON"/>
    <set-variable variableName="extractJsondata" value="#[json:GetProjectResponse/GetProjectResult]" mimeType="application/json" doc:name="Variable"/>
    <set-payload value="#[flowVars.extractJsondata]" doc:name="Set Payload"/>
    <json:xml-to-json-transformer doc:name="XML to JSON"/>
    </flow>

有人可以告诉我我是否想念东西.

Can someone tell me if I am missing something.

谢谢

推荐答案

少量检查

  1. 检查您的xml是否是您的Web服务真正寻找的确切格式.或

  1. Check whether your xml is the exact format which your webservice is really looking for. or

将编码从encoding='windows-1252'更改为UTF-8.请遵循url mule esb中的输出编码问题.或

Change the encoding from encoding='windows-1252' to UTF-8. Follow the url Output Encoding issue in mule esb. or

作为试用版和错误版,直接使用邮递员中的xml来访问Web服务(而无需进行数据编织来进行转换).或

As trial and error version directly use the xml in postman to hit webservice ( without making dataweave to do the transformation). or

在开始使用xml更大的sysmbol标记之前,请确保没有空格<?xml version='1.0' encoding="UTF-8"?>.

Make sure you have no space <?xml version='1.0' encoding="UTF-8"?> before starting of xml greater sysmbol tag.

检查以上4个步骤,可能会导致问题.第3步将有助于测试.

Check the above 4 steps anyone of this might cause issue. Step 3 will be helpful for testing.

这篇关于将http标头值传递给Web服务使用者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆