使用固定soap请求Mule-wrap http参数

使用固定soap请求Mule-wrap http参数,http,soap,xpath,mule,mule-studio,Http,Soap,Xpath,Mule,Mule Studio,我应该使用什么转换器从http消息(如http)中提取参数http://localhost:8088/?id=xxx&type=yyyyans将id和type参数的值放入固定的soap请求中,如: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsd="http://wsdouane/"> <soapenv:Header/> <soape

我应该使用什么转换器从http消息(如
http)中提取参数http://localhost:8088/?id=xxx&type=yyyy
ans将
id
type
参数的值放入固定的soap请求中,如:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsd="http://wsdouane/">
   <soapenv:Header/>
   <soapenv:Body>
      <wsd:find>
         <entity>
            <id>xxxx</id>
            <type>yyyy</type>
         </entity>
      </wsd:find>
   </soapenv:Body>
</soapenv:Envelope>
文件输出

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:findResponse xmlns:ns2="http://wsdouane/"/>
</S:Body>
</S:Envelope>

为了传递给JAX-WS web服务


谢谢

在对象中检索查询参数并将其设置为SOAP对象的过程并不是一个带有单个转换器的单步过程

第一步:你可以使用

 <http-request-to-parameter-map>

transformer将查询参数作为映射获取

步骤2:然后使用此贴图创建一个具有贴图vlaues的对象

步骤3:然后将对象发送到JAX-WS客户端组件

在下面的链接中可以找到更多关于转换器以及http和servlet模块引用的参考

更新了使用XSLT和代理客户端的答案

    <flow name="SOAPWebService" >

    <http:inbound-endpoint address="http://localhost:8088/"   exchange-pattern="request-response">          
    </http:inbound-endpoint>

    <set-variable value="#[message.inboundProperties['id']]" variableName="paramId"></set-variable>
    <set-variable value="#[message.inboundProperties['type']]" variableName="paramType"></set-variable>

    <component class="com.example.components.SampleComponent" ></component>

    <mule-xml:xslt-transformer
        maxIdleTransformers="2" maxActiveTransformers="5"
        xsl-file="C:\WorkSpace\MyProject\src\main\resources\xslt\PrepareRequestXML.xsl">
        <mule-xml:context-property key="paramId"
            value="#[flowVars['paramId']]" />
        <mule-xml:context-property key="paramType"
            value="#[flowVars['paramType']]" />
    </mule-xml:xslt-transformer>

    <cxf:proxy-client payload="body"
        enableMuleSoapHeaders="true">           
    </cxf:proxy-client>
    <http:outbound-endpoint exchange-pattern="request-response"
        address="http://localhost:8080/ClientsDB/douane" doc:name="HTTP">
    </http:outbound-endpoint>   

    <byte-array-to-string-transformer   doc:name="Byte Array to String" />      
    <file:outbound-endpoint ....... .. />
</flow>     

下面是正确的XSLT

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns="http://wsdouane/">
    <xsl:output method="xml" indent="yes" />
    <xsl:param name="paramType"></xsl:param>
    <xsl:param name="paramId"></xsl:param>

    <xsl:template match="*" >
        <xsl:element name="find" namespace="http://wsdouane/">
        <xsl:element name="entity">
         <xsl:element name="id">
           <xsl:value-of select="$paramType"/>
         </xsl:element>
         <xsl:element name="type">
            <xsl:value-of select="$paramId"/>
         </xsl:element> 
       </xsl:element>        
      </xsl:element>
    </xsl:template>

    <xsl:template match="text()|processing-instruction()|comment()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>    

SampleComponent类的代码是

package com.example.components;

import org.mule.api.MuleEventContext;
import org.mule.api.lifecycle.Callable;

public class SampleComponent implements Callable {
    @Override
    public Object onCall(MuleEventContext eventContext) throws Exception {
        String str = "<sample> </sample>";
        return str;
    }
}  
package com.example.components;
导入org.mule.api.MuleEventContext;
导入org.mule.api.lifecycle.Callable;
公共类SampleComponent实现了可调用{
@凌驾
公共对象onCall(MuleEventContext eventContext)引发异常{
字符串str=“”;
返回str;
}
}  

谢谢您的回复,但如果我避免使用SOAP组件,只需将参数插入SOAP请求并将xml直接传递给服务,那会更好,还有其他选择吗?我已经尝试过类似上面的方法,但它不起作用,您可以查看此线程,谢谢,谢谢你的帮助,我想直到变压器没有问题为止。在封送对象以发布SOAP请求时发生问题。您是否尝试将JAXB上下文添加到配置中。因此,您创建的对象可以轻松地进行marchalled。喜欢这里的构造函数arg是ObjectFactory类可用的包。我应该将它放在转换器和soap组件之间吗??它代表什么?更新了xslt,为您提供了一个合适的名称空间xml。在发布到jax-ws服务之前,我可以看到请求是正确生成的。如果这没有给出所需的响应,请与您呼叫的服务联系。从客户端看,请求看起来不错。这应该可以解决你在问题中提出的问题。
package com.example.components;

import org.mule.api.MuleEventContext;
import org.mule.api.lifecycle.Callable;

public class SampleComponent implements Callable {
    @Override
    public Object onCall(MuleEventContext eventContext) throws Exception {
        String str = "<sample> </sample>";
        return str;
    }
}