2009-05-14 1 views
2

java axis2 1.4.1 웹 서비스와 .net 3.5 WCF 클라이언트를 작성했으며 wsdl 결함을 잡으려고합니다.WCF FaultException이 발생합니까? <T>은 Java 웹 서비스와의 interop를 지원합니다. 결함

.net 3.5와 달리 .net 3.5는 wsdl:fault을 지원한다고 주장하며 서비스 참조 마법사는 클라이언트 프록시에서 모든 올바른 오류 클래스를 생성합니다. 내가 잘못을 잡으려고하지만 정확히 내가 실제로 던졌다 만 catch (FaultException ex) 아닌 유형 내 reference.cs 나는 마법사가 추가되었습니다 볼 수있는 내부 모양을했다 FaultException<T>

사용 할 수 있도록에는 직렬화하지 않는 것 내 opeation에 FaultContract을 수정하십시오.

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] 
[System.ServiceModel.ServiceContractAttribute(Namespace="http://www.mycomp.com/wsdl/Foo", ConfigurationName="FooServiceProxy.Foo")] 
public interface Foo { 

     [System.ServiceModel.OperationContractAttribute(Action="http://www.mycomp.com/Foo/list", ReplyAction="*")] 
[System.ServiceModel.FaultContractAttribute(typeof(TestWsdlFaultsApp.FooServiceProxy.SimpleFault), Action="http://www.mycomp.com/Foo/list", Name="simpleFault")] 
     [System.ServiceModel.XmlSerializerFormatAttribute()] 
     TestWsdlFaultsApp.FooServiceProxy.listResponse list(TestWsdlFaultsApp.FooServiceProxy.listRequest request); 
    } 

.net이 필요로하는 다른 기능이 있습니까? 또는 WCF는 .net 웹 서비스에서 사용자 지정 wsdl 오류 만 지원합니까?

Heres는 내 WSDL

<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet type="text/xsl" href="wsdl-viewer.xsl"?> 
<wsdl:definitions name="FooImplDefinitions" 
     targetNamespace="http://www.mycomp.com/wsdl/Foo" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
     xmlns:tns="http://www.mycomp.com/wsdl/Foo" 
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:xs="http://www.w3.org/2001/XMLSchema"> 

     <!-- TYPES --> 
     <wsdl:types> 
      <xs:schema targetNamespace="http://www.mycomp.com/wsdl/Foo" 
        elementFormDefault="qualified" attributeFormDefault="unqualified" 
        xmlns:security="http://www.mycomp.com/xsd/types/Security"> 

        <!-- IMPORTS --> 
        <xs:import namespace="http://www.mycomp.com/xsd/types/Foo" 
         schemaLocation="Foo.xsd" /> 
        <xs:import namespace="http://www.mycomp.com/xsd/types/Security" 
         schemaLocation="Security.xsd" /> 

        <!-- HEADER ELEMENTS --> 
        <xs:element name="identity" type="security:TrustedIdentity" /> 

        <!-- REQUEST/RESPONSE ELEMENTS --> 
        <xs:element name="listRequest"> 
         <xs:complexType> 
           <xs:sequence> 
            <xs:element name="action" type="xs:string" /> 
           </xs:sequence> 
         </xs:complexType> 
        </xs:element> 
        <xs:element name="listResponse"> 
         <xs:complexType> 
           <xs:sequence> 
            <xs:element name="stuff" type="xs:string" /> 
           </xs:sequence> 
         </xs:complexType> 
        </xs:element> 

        <!-- FAULT TYPES --> 
        <xs:complexType name="SimpleFault"> 
         <xs:sequence> 
           <xs:element name="reason" type="xs:string"/> 
         </xs:sequence> 
        </xs:complexType> 

        <!-- FAULT ELEMENTS --> 
        <xs:element name="simpleFault" type="tns:SimpleFault"/> 
      </xs:schema> 
     </wsdl:types> 

     <!-- MESSAGES --> 
     <wsdl:message name="listRequest"> 
      <wsdl:part element="tns:listRequest" name="parameters" /> 
      <wsdl:part element="tns:identity" name="header" /> 
     </wsdl:message> 
     <wsdl:message name="listResponse"> 
      <wsdl:part element="tns:listResponse" name="return" /> 
     </wsdl:message> 
     <wsdl:message name="simpleException"> 
      <wsdl:part element="tns:simpleFault" name="fault"/> 
     </wsdl:message> 

     <!-- PORT TYPES --> 
     <wsdl:portType name="Foo"> 
      <wsdl:operation name="list"> 
        <wsdl:input message="tns:listRequest" /> 
        <wsdl:output message="tns:listResponse" /> 
        <wsdl:fault name="simpleFault" message="tns:simpleException" /> 
      </wsdl:operation> 
     </wsdl:portType> 

     <!-- BINDINGS --> 
     <wsdl:binding name="FooBinding" type="tns:Foo"> 
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
      <wsdl:operation name="list"> 
        <soap:operation soapAction="http://www.mycomp.com/Foo/list" /> 
        <wsdl:input> 
         <soap:header message="tns:listRequest" part="header" use="literal" /> 
         <soap:body parts="parameters" use="literal" /> 
        </wsdl:input> 
        <wsdl:output> 
         <soap:body use="literal" /> 
        </wsdl:output> 
        <wsdl:fault name="simpleFault"> 
         <soap:fault name="simpleFault" use="literal" /> 
        </wsdl:fault> 
      </wsdl:operation> 
     </wsdl:binding> 

     <!-- SERVICES --> 
     <wsdl:service name="FooServiceImpl"> 
      <wsdl:port name="FooPort" binding="tns:FooBinding"> 
        <soap:address 
         location="http://localhost:9001/Foo/FooServiceImpl" /> 
      </wsdl:port> 
     </wsdl:service> 

</wsdl:definitions> 

답변

1

옳은 길로 나를 설정해 주셨습니다. 문제점은 분명했습니다. java (axis2)로 오류를 던졌을 때 세부 사항을 설정하지 않았습니다.

사기 CODE :

throw new SimpleException("SimpleFault thrown"); 

일하고 CODE :

SimpleFault fault = new SimpleFault(); 
fault.setReason("SimpleFault reason"); 

SimpleFaultE faultMessage = new SimpleFaultE(); 
faultMessage.setSimpleFault(fault); 

SimpleException ex = new SimpleException("SimpleFault thrown"); 
ex.setFaultMessage(faultMessage); 

throw ex; 

그래서 AXIS2 -> WCF의 WSDL은 : 장애 상호 운용성 작동 잘 ...

1

는 WCF는, 축 예외와 함께 작동합니다. 나는 그것을 작동 시켰지만 모든 세부 사항을 기억하지는 못한다.

SOAP 모니터 또는 이와 유사한 것을 사용할 때 오류 메시지 본문에 무엇을 표시합니까?

1

FaultException<T>을 잡지 않으면 전송하지 않을 가능성이 있습니다. XML 네임 스페이스가 사용되는 것에주의하십시오. 피들러 (Fiddler) 또는 그와 유사한 것을 사용하여 보내는 것을보십시오.

FaultException<T>은 Java 또는 WCF에서도 잘 작동합니다.