處理SOAP錯誤響應我在騾子代理web服務,我現在用XSLT轉換響應修改響應......它工作正常,並響應有點像: -如何使用XSLT
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<retrieveDataResponse xmlns="http://services.test.com/schema/MainData/V1">
<Response>The Data retrieved from the Database</Response>
<Id>3</Id>
<Name>anir</Name>
<Age>44</Age>
<Designation>SE</Designation>
</retrieveDataResponse>
</soap:Body>
</soap:Envelope>
現在的問題是,當出現任何SOAP錯誤說UNMARSHAL_ERROR,響應不表明SOAP錯誤......它有點像: -
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<retrieveDataResponse xmlns="http://services.test.com/schema/MainData/V1">
<Response/>
</retrieveDataResponse>
</soap:Body>
</soap:Envelope>
但它應該顯示SOAP錯誤 ...如果我從響應中刪除XSLT,它將正常工作,並顯示與SOAP Fault ..的響應,但是如果我再次放置XSLT,它不會顯示錯誤響應。我如何修改我的XSLT以便它處理SOAP故障.....我的XSLT如下: -
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:md1="http://services.test.com/schema/MainData/V1"
exclude-result-prefixes="md1">
<xsl:template match="/">
<soap:Envelope>
<soap:Body>
<retrieveDataResponse xmlns="http://services.test.com/schema/MainData/V1">
<Response>
<xsl:value-of
select="soap:Envelope/soap:Body/md1:retrieveDataResponse/md1:Response" />
</Response>
<xsl:if
test="soap:Envelope/soap:Body/md1:retrieveDataResponse/md1:Response='The Data retrieved from the Database'">
<Id>
<xsl:value-of
select="soap:Envelope/soap:Body/md1:retrieveDataResponse/md1:Id" />
</Id>
<Name>
<xsl:value-of
select="soap:Envelope/soap:Body/md1:retrieveDataResponse/md1:Name" />
</Name>
<Age>
<xsl:value-of
select="soap:Envelope/soap:Body/md1:retrieveDataResponse/md1:Age" />
</Age>
<Designation>
<xsl:value-of
select="soap:Envelope/soap:Body/md1:retrieveDataResponse/md1:Designation" />
</Designation>
</xsl:if>
</retrieveDataResponse>
</soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:stylesheet>
請幫助...如何修改我的XSLT趕上SOAP錯誤
您的curretn XSLT只是通過SOAP Envelope來重現RetrieveDataResponse XMl,它作爲響應接收。你爲什麼使用XSLT呢? – user1760178