【问题标题】:Parsing MuleSoft CXF Request解析 MuleSoft CXF 请求
【发布时间】:2018-02-09 23:36:47
【问题描述】:

我正在尝试解析我在 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>

MULE 入站消息详细信息:

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:
}

【问题讨论】:

  • 您的意思是要从示例请求中提取节点值??
  • CXF 自动从信封中提取皂体,即; &lt;notifications&gt;...&lt;/notifications&gt;。之后使用 dataweave 或 xpath 从中提取值。

标签: java soap mule


【解决方案1】:

您可以使用下面的简单 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>

【讨论】:

    【解决方案2】:

    您可以使用带有代理服务操作的 CXF 组件来提取 SOAP 消息体作为有效负载 例如:

      <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-26
      • 2019-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-03
      相关资源
      最近更新 更多