【发布时间】:2014-09-12 14:12:31
【问题描述】:
我有一个与 Web 服务对话的 Apache camel 应用程序。我需要将响应肥皂消息转换/解组为代理对象。我没有使用soap数据格式,而是使用jaxb转换,为此我需要首先从soap消息中提取xml。当我从命令行运行我的应用程序时,以下 xsl 和 soap 响应工作正常,但如果我在 JBoss eap 6.2 GA 上部署我的应用程序,它会失败。我的xsl,示例响应soap消息和生成的xml如下,
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
version="1.0">
<xsl:output method="xml" indent="no" />
<xsl:strip-space elements="*" />
<xsl:template match="/*">
<xsl:copy-of select="/soapenv:Envelope/soapenv:Body/*" />
</xsl:template>
<xsl:template match="/*">
<xsl:copy-of select="/s:Envelope/s:Body/*" />
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
示例soap消息是:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId CorrelationId="8877bd15-990e-465f-acca-3b2f21945735"
xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">b0480ae4-7692-4224-9082-662cbe8a6edc</ActivityId>
</s:Header>
<s:Body>
<GetUserByEmailResponse xmlns="urn:RetailApi/AccountManagementService/v2">
<GetUserByEmailResult xmlns:a="urn:RetailApi/Schemas/v2"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:EmailAddress>a@b.com</a:EmailAddress>
<a:FirstName>Scott</a:FirstName>
<a:LastName>Tiger</a:LastName>
<a:MobilePhoneNumber>3232326565</a:MobilePhoneNumber>
<a:Title>Mr</a:Title>
<a:UserId>xxxxx</a:UserId>
</GetUserByEmailResult>
</GetUserByEmailResponse>
</s:Body>
生成的xml是:
<?xml version="1.0" encoding="UTF-8"?>< xmlns="urn:RetailApi/AccountManagementService/v2"><><a:EmailAddress xmlns:a="urn:RetailApi/Schemas/v2">a@b.com</a:EmailAddress><a:FirstName xmlns:a="urn:RetailApi/Schemas/v2">Scott</a:FirstName><a:LastName xmlns:a="urn:RetailApi/Schemas/v2">Tiger</a:LastName><a:MobilePhoneNumber xmlns:a="urn:RetailApi/Schemas/v2">3232326565</a:MobilePhoneNumber><a:Title xmlns:a="urn:RetailApi/Schemas/v2">Mr</a:Title><a:UserId xmlns:a="urn:RetailApi/Schemas/v2">xxxx</a:UserId></></>
如您所见,生成的 xml 有几个问题。 之间有一个空格。最后有几个空白/空节点,如 。此外,这对节点丢失了。即 GetUserByEmailResponse 和 GetUserByEmailResult,我得到一个空白节点,例如 。
在 jboss 应用服务器上部署并运行代码后,我得到:com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) in prolog, after '<'.
此问题仅在我通过应用服务器运行我的应用程序时发生,并且在我作为独立应用程序运行时不会发生。
非常感谢任何帮助。
【问题讨论】:
标签: xml xslt soap apache-camel jboss6.x