問題はこの質問に似ています。WCFFaultException<T>はJavaWebサービスFaultとの相互運用をサポートしていますか。ただし、私の場合、カスタム障害は実際にサービスから返されます。
これを説明するのは難しいですが、ここに行きます:
新しいWCFクライアントから、既存のJava Webサービス(他の種類のクライアントで何年もうまく機能している)を呼び出しています。サービスXSDは、1つのカスタム障害ServiceFaultを定義します。
<xs:complexType name="ServiceFault">
<xs:annotation>
<xs:documentation>On service error</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="ErrorCode" type="xs:string"/>
<xs:element name="ErrorDescription" type="xs:string"/>
</xs:all>
</xs:complexType>
このServiceFaultは、より具体的なすべてのカスタム障害(MyMethodFaultなど)に使用されるため、次のようにすべてErrorCodeプロパティとErrorDescriptionプロパティを取得します。
<xs:element name="MyMethodFault" type="ServiceFault">
<xs:annotation>
<xs:documentation>On error in MyMethod</xs:documentation>
</xs:annotation>
</xs:element>
次に、障害のWSDLメッセージが次のように定義されます。
<wsdl:message name="MyMethodFault">
<wsdl:part element="tns:MyMethodFault " name="MyMethodFault">
</wsdl:part>
そして最後に、操作は次のようにこれらの障害で定義されます。
<wsdl:fault message="tns:MyMethodFault" name="MyMethodFault">
これまでのところ、私には良さそうです。そして実行時に、サービスは次のように詳細SOAPタグで障害をきちんと返します。
<ns2:MyMethodFault xmlns:ns2="urn:salessystem:entity:MyService:v1.0">
<ns2:ErrorCode>1000</ns2:ErrorCode>
<ns2:ErrorDescription>TheErrorDescr</ns2:ErrorDescription>
</ns2:MyMethodFault>
ただし、SvcUtilは、より具体的なカスタムフォールトを生成せず、ServiceFaultのみを生成しました。これは、サービスリファレンスでのMyMethodFaultの唯一の言及です。
[OperationContractAttribute(Action = "", ReplyAction = "*")]
[FaultContractAttribute(typeof(sale...ServiceFault), Action="", Name="MyMethodFault")]
[ServiceKnownTypeAttribute(typeof(ServiceFault))]
MyMethodResponse MyMethod(MyMethodRequest1 request);
だから、ここに問題があります:
MyMethodFaultが存在しないため、キャッチできませんFaultException<MyMethodFault>.
。さらに、WCFは実行時にMyMethodFaultなどの特定のフォールトをServiceFaultにマップしないため、タイプの例外がFaultException<ServiceFault>
キャッチされることはありません。したがって、エラーの説明は表示されません。
私は何か間違ったことをしていますか、それともWSDLまたはSvcUtil-usageを微調整する必要がありますか?
誰もが質問を理解できることを願っています:P
ありがとう、ビョルン