Pergunta

Eu escrevi uma eixo2 1.4.1 serviço web java e .net cliente 3,5 WCF e estou tentando pegar as falhas WSDL jogados.

Ao contrário NET 2.0 do NET 3.5 reivindicações de wsdl:fault apoio e o assistente de referência de serviço faz gerar todas as classes de falhas corretas no proxy do cliente. Mas quando eu tento pegar uma falha que não parece corretamente serialise modo que eu só posso catch (FaultException ex) e não do tipo I, na verdade, jogou usando FaultException<T>

Eu tinha um olhar dentro dos meus Reference.cs eu posso ver FaultContract correta assistente tiver adicionado à minha opeation.

[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);
    }

Há outra coisa que eu preciso fazer em .NET para chegar a este trabalho? ou não WCF suportam apenas falhas costume WSDL de um serviço .net web?

Heres meu 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>
Foi útil?

Solução 3

Graças john você me colocou no caminho certo, problema era óbvio: Eu não estava definindo os detalhes quando eu joguei a culpa em java (eixo2).

desonesto código:

throw new SimpleException("SimpleFault thrown");

TRABALHO CÓDIGO:

 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;

Assim Axis2 -> WCF wsdl: interoperabilidade culpa funciona muito bem ...

Outras dicas

WCF deve trabalhar com exceções Axis2. Eu tinha que trabalhar, mas eu não me lembro de todos os detalhes.

Quando você usa Monitor SOAP ou algo assim, o que você vê no corpo da mensagem culpa?

Se você não está pegando o FaultException<T>, isso significa que você provavelmente não enviá-lo. Tenha cuidado com o namespace XML que está sendo usado. Dê uma olhada no que você está enviando, usando Fiddler ou algo parecido.

FaultException<T> funciona bem com Java, ou mesmo com o WCF.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top