我正在創建一個Web服務,我公司的內部客戶端將會調用它。服務方法如下所示:創建SOAP錯誤響應
CreateProposalResponse ProposalSOAService :: CreateProposal(CreateProposalRequest)
對於CreateProposalResponse消息我需要的業務錯誤信息添加到響應。我一直在閱讀很多有關將錯誤放入SOAP Headers的問題,但對於業務錯誤,我不認爲這是放置它們的適當位置,因爲這應該是系統/傳輸/驗證類型的錯誤而不是業務錯誤。以下是我對CreateProposal()SOA調用的響應XML。有人可以告訴我如何將錯誤消息添加到此響應中嗎?我很難想象這一點,以及呼叫客戶如何確定與正常響應和業務錯誤/異常的區別。
我CreateProposalResponse消息如下所示:
<?xml version="1.0" encoding="UTF-8" ?>
<CreateProposalResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.xxx.com/aces/proposal src/Proposal_v1.0.xsd"
xmlns="http://xmlns.raytheon.com/aces/proposal">
<userId>022483</userId>
<Proposal>
<proposalTitle>SBT Prop</proposalTitle>
<proposalDescription>Proposal is for SBT</proposalDescription>
<businessSegmentCode>SAS</businessSegmentCode>
<proposalType>Test</proposalType>
<proposalExternalRefID>SBT38829</proposalExternalRefID>
<proposalStartDate>2009-01-01</proposalStartDate>
<proposalEndDate>2025-01-01</proposalEndDate>
</Proposal>
<sourceSystemID>SBT</sourceSystemID>
<targetSystemID>ACES</targetSystemID>
</CreateProposalResponse>
謝謝你已經證實我覺得這是正確的做法。 –