我有一個BizTalk 2009業務流程,其中包含作爲WCF基本HTTP Web服務發佈的請求 - 響應端口類型。端口有一個操作,並且該操作具有適當模式的請求和響應消息。在此端口上收到請求後,有幾種情況應將錯誤消息返回給客戶端而不是標準響應消息。我很難將正確的錯誤信息返回給客戶端。我希望能夠設置SOAP故障消息的faultcode
和faultstring
元素。以下是我嘗試過的:BizTalk業務流程:使用非類型化SOAP錯誤進行響應
添加類型爲字符串的故障消息: 我試圖向操作添加帶有消息類型字符串的故障消息。在編排中,我構造了一個字符串消息並將其作爲響應發送。以後被輸送回客戶機故障看起來像:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
<faultstring xml:lang="en-US"><?xml version="1.0" encoding="utf-8"?>
<string>This is the error message.</string></faultstring>
<detail>
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message><?xml version="1.0" encoding="utf-8"?>
<string>This is the error message.</string></Message>
<StackTrace>at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkAsyncResult.End() ...</StackTrace>
<Type>Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkNackException</Type>
</ExceptionDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
這幾乎工程,除faultstring
元素包含我的字符串的XML序列版本,而不是字符串本身。我也不能設置faultcode
元素。
添加http://schemas.xmlsoap.org/soap/envelope/#Fault
類型的故障信息我想如果我構建了Fault
元並送我也許能說服的BizTalk返回沿着我所期待什麼線路故障消息。因此,我添加了一條類型爲http://schemas.xmlsoap.org/soap/envelope/#Fault
的故障消息,構建了適當的消息並將其作爲響應發送。結果與上面相同,除了代替字符串,faultstring
元素包含一個CDATA
部分,其中包含我在裏面構建的整個xml消息。
所以我現在卡住了;我覺得這應該是BizTalk中的一個簡單任務。 MSDN上的文檔How to Throw Fault Exceptions from Orchestrations Published as WCF Services告訴您除了可以拋出錯誤並且需要在配置中設置includeExceptionDetailInFaults
(我已經完成)之外,拋出錯誤異常的方式。
有沒有人有任何建議如何在BizTalk 2009中實現?
沒有什麼是簡單的BizTalk :) – Nix 2010-10-14 20:00:12
@Nix:同意!我沒有說它*很簡單,只是它*應該*而已。 – 2010-10-14 20:10:00