0

I am consuming JAVA service everything working fine but faultexception are giving me trouble. fault exception is not getting de-serialized properly. due to some name space issue. this is the wsdl.

    <?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://gpp.pb.com/services/indicia/v1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="DispenseService" targetNamespace="http://gpp.pb.com/services/indicia/v1">
  <wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://gpp.pb.com/services/indicia/v1" elementFormDefault="qualified" targetNamespace="http://gpp.pb.com/services/indicia/v1" version="1.0">
<xs:element name="createBulkIndiciumRequest" type="tns:createBulkIndiciumRequest"/>
<xs:element name="createBulkIndiciumResponse" type="tns:createBulkIndiciumResponse"/>
<xs:element name="fault" type="tns:fault"/>
<xs:element name="faultError" type="tns:faultError"/>
<xs:complexType name="createBulkIndiciumRequest">
<xs:sequence>
<xs:element name="cultureCode" type="xs:string"/>
<xs:element name="carrier" type="tns:carrier"/>
<xs:element name="partner" type="tns:partnerTxInfo"/>
<xs:element name="sync" type="xs:string"/>
<xs:element name="outputFormat" type="tns:outputFormat"/>
<xs:element name="outputFormatReturnType" type="tns:outputFormatReturnType"/>
<xs:element maxOccurs="unbounded" name="indicium" type="tns:indiciumRequest"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="partnerTxInfo">
<xs:sequence>
<xs:element name="partnerId" type="xs:int"/>
<xs:element name="partnerBulkTransactionId" type="xs:string"/>
<xs:element name="partnerTransactionDateTime" type="xs:string"/>
<xs:element minOccurs="0" name="paymentAccountId" type="xs:int"/>
<xs:element minOccurs="0" name="senderUserId" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="indiciumRequest">
<xs:sequence>
<xs:element name="partnerTransactionId" type="xs:string"/>
<xs:element name="originPostalCode" type="xs:string"/>
<xs:element name="dateOfShipment" type="xs:string"/>
<xs:element minOccurs="0" name="serviceName" type="xs:string"/>
<xs:element minOccurs="0" name="serviceOption" type="xs:string"/>
<xs:element name="totalPostageCharge" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="createBulkIndiciumResponse">
<xs:sequence>
<xs:element name="correlationId" type="xs:string"/>
<xs:element name="carrier" type="tns:carrier"/>
<xs:element name="partner" type="tns:partnerTxInfo"/>
<xs:element maxOccurs="unbounded" name="indicium" type="tns:indiciumResponse"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="indiciumResponse">
<xs:sequence>
<xs:element name="partnerTransactionId" type="xs:string"/>
<xs:element name="totalPostageCharge" type="xs:decimal"/>
<xs:element name="meterId" type="xs:string"/>
<xs:element name="meterCurrentRegisterAmount" type="tns:meterRegisterAmount"/>
<xs:element name="url" type="xs:string"/>
<xs:element name="stream" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="fault" nillable="true" type="tns:faultError"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="meterRegisterAmount">
<xs:sequence>
<xs:element minOccurs="0" name="ascendingRegister" type="xs:decimal"/>
<xs:element minOccurs="0" name="descendingRegister" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="faultError">
<xs:sequence>
<xs:element name="errorCode" type="xs:string"/>
<xs:element name="errorDescription" type="xs:string"/>
<xs:element minOccurs="0" name="errorAdditionalInfo" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fault">
<xs:sequence>
<xs:element name="detail" type="tns:detail"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="detail">
<xs:sequence>
<xs:element name="carrier" type="xs:string"/>
<xs:element name="correlationId" type="xs:string"/>
<xs:element name="partnerTxInfo" type="tns:partnerTxInfo"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="errors" nillable="true" type="tns:faultError"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="carrier">
<xs:restriction base="xs:string">
<xs:enumeration value="usps"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="outputFormat">
<xs:restriction base="xs:string">
<xs:enumeration value="pdf"/>
<xs:enumeration value="gif"/>
<xs:enumeration value="png"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="outputFormatReturnType">
<xs:restriction base="xs:string">
<xs:enumeration value="url"/>
<xs:enumeration value="base64"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
  </wsdl:types>
  <wsdl:message name="Fault_Exception">
    <wsdl:part element="tns:fault" name="detail" >
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="createBulkIndiciumResponse">
    <wsdl:part element="tns:createBulkIndiciumResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="createBulkIndicium">
    <wsdl:part element="tns:createBulkIndiciumRequest" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="dispense">
    <wsdl:operation name="createBulkIndicium">
      <wsdl:input message="tns:createBulkIndicium" name="createBulkIndicium">
    </wsdl:input>
      <wsdl:output message="tns:createBulkIndiciumResponse" name="createBulkIndiciumResponse">
    </wsdl:output>
      <wsdl:fault message="tns:Fault_Exception" name="Fault_Exception">
    </wsdl:fault>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="DispenseServiceSoapBinding" type="tns:dispense">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="createBulkIndicium">
      <soap:operation soapAction="http://gpp.pb.com/services/indicia/v1/createBulkIndicium" style="document"/>
      <wsdl:input name="createBulkIndicium">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="createBulkIndiciumResponse">
        <soap:body use="literal"/>
      </wsdl:output>
      <wsdl:fault name="Fault_Exception">
        <soap:fault name="Fault_Exception" use="literal"/>
      </wsdl:fault>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="DispenseService">
    <wsdl:port binding="tns:DispenseServiceSoapBinding" name="dispensePort">
      <soap:address location="http://gppprt1esb-ext.test.pb.com/services/indicia/v1/dispense"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

WCF is generating fault as

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.33440")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://gpp.pb.com/services/indicia/v1")]    
    public partial class fault : object, System.ComponentModel.INotifyPropertyChanged {

        private detail detailField;

        /// <remarks/>
        [System.Runtime.Serialization.DataMemberAttribute()]
        public detail detail {
            get {
                return this.detailField;
            }
            set {
                this.detailField = value;
                this.RaisePropertyChanged("detail");
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName) {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null)) {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }

anotations generated are wrong it is not making it datacontract.

if I change annotations it works

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name = "fault", Namespace = "http://com.pb.gpp/services/indicia/v1")]
[System.SerializableAttribute()] 

Not sure why WCF is not doing the same.

sandeep
  • 996
  • 2
  • 11
  • 22
  • IIRC Faults aren't Data Contracts and shouldn't be marked as such. Does it generate errors when compiled or when the endpoint returns a fault? – simon at rcl Aug 11 '14 at 16:25
  • @simon is not able to de-serialize fault when API send fault response. compilation is fine. – sandeep Aug 12 '14 at 09:56
  • I remembered wrong: Faults do have to have the DataContract annotation. Can you post the server-side definition of the fault class? – simon at rcl Aug 13 '14 at 07:38

0 Answers0