解析MuleSoft CXF请求

时间:2017-03-03 21:31:01

标签: java soap mule

我正在尝试解析我在MuleSoft中创建的一个端点上收到的请求。

这是来自Salesforce的SOAP请求,我不能仅仅获取XML并从中获取值。肥皂请求消息如下。

示例SOAP请求:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <notifications
            xmlns="http://soap.sforce.com/2005/09/outbound">
            <OrganizationId>00123jhk1h230AQ</OrganizationId>
            <ActionId>04215wergf2345AA0</ActionId>
            <SessionId>00Dn00000008w1T!AQ0AQLiuZg345345EGC8LAY00OqInU_Exn4.FVinnwwc2j.Naerwt2323g0R4qi9ykmHt.eertert212342dh</SessionId>
            <EnterpriseUrl>https://12fwghoft.cs50.my.salesforce.com/services/Soap/c/39.0/00Dn00000008w1T</EnterpriseUrl>
            <PartnerUrl>https://12fwghoft.cs50.my.salesforce.com/services/Soap/u/39.0/00Dn00000008w1T</PartnerUrl>
            <Notification>
                <Id>04l45611902IG</Id>
                <sObject xsi:type="sf:Account"
                    xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
                    <sf:Id>00q2sv2224ggwAV</sf:Id>
                </sObject>
            </Notification>
        </notifications>
    </soapenv:Body>
</soapenv:Envelope>

多个入站消息详情:

org.mule.DefaultMuleMessage
{
  id=114f2110-0058-11e7-9989-5ce0c55142df
  payload=[Ljava.lang.Object;
  correlationId=<not set>
  correlationGroup=-1
  correlationSeq=-1
  encoding=UTF-8
  exceptionPayload=<not set>

Message properties:
  INVOCATION scoped properties:
    _ApikitResponseTransformer_AcceptedHeaders=*/*
    _ApikitResponseTransformer_apikitRouterRequest=yes
    _ApikitResponseTransformer_contractMimeTypes=[]
    cxf_operation={http://soap.sforce.com/2005/09/outbound}notifications
    cxf_service={http://soap.sforce.com/2005/09/outbound}NotificationPortService
    method=public abstract boolean sfdc.account.NotificationPort.notifications(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.util.List)
  INBOUND scoped properties:
    accept-encoding=gzip
    cache-control=max-age=259200
    content-length=1028
    content-type=text/xml; charset=utf-8
    host=36ce69be.ngrok.io
    http.listener.path=/api/*
    http.method=POST
    http.query.params=ParameterMap{[]}
    http.query.string=
    http.relative.path=/api/netsuite/customers
    http.remote.address=/127.0.0.1:59266
    http.request.path=/api/netsuite/customers
    http.request.uri=/api/netsuite/customers
    http.scheme=http
    http.uri.params=ParameterMap{[]}
    http.version=HTTP/1.1
    soapaction=""
    user-agent=Jakarta Commons-HttpClient/3.1
    x-forwarded-for=136.147.62.8
  OUTBOUND scoped properties:
    MULE_ENCODING=UTF-8
  SESSION scoped properties:
}

2 个答案:

答案 0 :(得分:0)

您可以使用以下简单的xsl代码和XSLT转换器步骤提取SOAP消息正文部分xml。

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:outbound="http://soap.sforce.com/2005/09/outbound">
        <xsl:template match="/">
         <xsl:copy-of select="/soapenv:Envelope/soapenv:Body/outbound:notifications"/>
        </xsl:template>
    </xsl:stylesheet>

答案 1 :(得分:0)

您可以将CXF组件与代理服务操作一起使用,以便将SOAP邮件正文提取为Payload  例如:

  <cxf:proxy-service port="tmddOCSoapHttpServicePort" namespace="http://www.tmdd.org/3/dialogs" service="TmddOwnerCenterService" payload="body" wsdlLocation="classpath:/TMDD.wsdl" enableMuleSoapHeaders="false" metadata:id="533a80dc-8f06-42c6-9646-a461196dfd72" doc:name="TmddOwnerCenterService">
  </cxf:proxy-service>