none
Problem catching SoapException

    Question

  • I'm developing e webclient. Evrey thin works fine but in case of the response is null a Soapexception should be thrown.
    The sopaexception contains the arror code and the information.

    Instead of that, a FormatException ist thrown wit the message:
    "Weitere XML-Inhalte sind im Fehlerdetailelement vorhanden. Nur ein einzelnes Element ist zulässig."
    "Error detail contains additional XML-Contents. Only a single Element is allowed.

    Does any one of you know what the problem is?
    Tuesday, July 14, 2009 5:13 PM

All replies

  • Hi,

    Could you please provide more info of the service you're trying to call?.

    Thanks,
    Rodrigo.
    Tuesday, July 14, 2009 5:44 PM
  •  

    This is the test code. As you can see there are two different Exception parts.
    Whenever the search criteria does not match a soapexception shoul be thrown with the according exception code and text.


    private
    ResultObject CallWsServiceCustomBinding(string pWebReference)

    {

     

          OrganisationList orgList = null;

     

          OrgSearchSoapPortChannel client = null;

     

         try

         {

     

     

             SecurityBindingElement security = SecurityBindingElement.CreateUserNameOverTransportBindingElement();

     

             BindingElementCollection bindingElements = new BindingElementCollection();

     

             HttpsTransportBindingElement httpsBindingElement = new HttpsTransportBindingElement();

     

             CustomTextMessageBindingElement textBindingElement = new CustomTextMessageBindingElement();

             bindingElements.Add(security);

             bindingElements.Add(

    new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8));

             bindingElements.Add(httpsBindingElement);

             bindingElements.Find<

    SecurityBindingElement>().IncludeTimestamp = false;

     

             CustomBinding binding = new CustomBinding(bindingElements);

     

             EndpointAddress pEndpointAddress = new EndpointAddress(pWebReference);

     

             ChannelFactory<OrgSearchSoapPortChannel> factory = new ChannelFactory<OrgSearchSoapPortChannel
             (binding,  EndpointAddress);

             factory.Endpoint.Behaviors.Add(

    new MustUnderstandBehavior(true));

             factory.Credentials.CreateSecurityTokenManager();

             factory.Credentials.UserName.UserName =

    "USERNAME";

             factory.Credentials.UserName.Password =

    "password";

             client = factory.CreateChannel();

            

    OrgSearchRequest orgRequest = new OrgSearchRequest();

     

             OrganisationSearchRequest lOrganisationSearchRequest = new OrganisationSearchRequest();

             lOrganisationSearchRequest.getOrganisationsRequest = orgRequest;

             orgRequest.MaxOrg =

    "25";

             orgRequest.SearchType =

    "ALL";

     

             SearchOrganisation search = null;

     

             if (search == null)

                  search =

    new SearchOrganisation();

     

             NameAddress nameAddress = new NameAddress();

     

             Country country = new Country();

             country.Item =

    "DEU";

             nameAddress.Country = country;

     

            Address adress = new Address();

            adress.Street =

    new Street();

            adress.Street.Items =

    new string[] { "" };

            adress.City =

    "";

            nameAddress.Address = adress;

     

            Name name = new Name();

            name.Items =

    new string[] { "cbcvbcvbcvbcvbcbc" };

            nameAddress.Name = name;

            search.NameAddress = nameAddress;

            orgRequest.SearchOrganisation = search;

     

     

            List<SimpleOrganisation> simpleOrgList = null;

     

            orgList = client.getOrganisations(lOrganisationSearchRequest).getOrganisationsReturn;

        }

     

        catch (SoapException soapExp)

        {

               mResultObject.ErrorValue = -1;

               mResultObject.ErrorText = soapExp.Message;

        }

     

        catch (Exception exp)

        {

              mResultObject.ErrorValue = -1;

             mResultObject.ErrorText = exp.Message;

         }

     

         finally

        {

                mResultObject.LogData +=

    "\n" + lCoverDecision.OrgSerachLogData();

         }

     

          return mResultObject;

    }

    Wednesday, July 15, 2009 7:13 AM
  • Hi,

    This seems to be the client-side code, right?.
    Actually I just wanted to know more of the service itself.... is a WCF service?... what exception are you throwing from there?... how is it configured?.

    SoapExceptions was the SOAP Faults exception wrapper for ASMX Web Services.... the WCF counterpart is the FaultException class.... so, if the service is a WCF service you should expect to receive a FaultException and not a SoapException....

    I wanted to see more on the service-side to understand why would you get a FormatException in this case....

    Regards,
    Rodrigo.
    Wednesday, July 15, 2009 7:23 AM
  • Hi YDogan,

    I think the exception is possibly raised at the client-side when deseralizing the response message(you need to check the exception callstack to verify it). You can directly attach the debugger to client process or turn on WCF trace on client-side for capturing exception details.  Generally the response message content should not be none and for xml soap based distrubuted communication (Webservice or WCF) ,they will not directly return the strong-type(.NET coupled) excetpion instance to client, but will further wrapper them with a SoapException or FaultException.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, July 17, 2009 2:32 AM
  • Hi rfreire,

    the service is developed under java-axis and is throwing a soap-exception. I don't have the code of the service. 
    I also tried with the FaultException, but this does not help much.
    I have also a client which is written with wse and it works fine. There i'm getting a soap-exception wthout any problem.
    But i have to develope this client under wcf. I assume i musst change some thing in bindings? because I'm getting a format exception.

    I have a trace toole and there i can see that am getting the exception-xml, but it is not possible to access to the detail part of the exception, because there is only one message part , which contains the message above.

    Monday, July 20, 2009 8:01 AM
  • Hi YDogan,

    Have you tried checking the callstack as I've mentioned in previous thread? Since the service is a java-axis one, then there is no reason it will throw an .NET type exception. So that exception is a client-side one. If you want to access the underlying soap exception xml, you can use a custom soapExtension to intercept the response message.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, July 23, 2009 3:01 AM
  • Your service is in Java. If it throws an exception named "SoapException", then that is a Java class named "SoapException". It will have nothing to do with any exceptions in .NET. Also, you WSE code is using ASMX technology, which, as has been said, also used a class named SoapException.

    You should experiment - catch (Exception ex) then look in the debugger to see what  type you get back.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    • Marked as answer by YDogan Monday, July 27, 2009 11:14 AM
    • Unmarked as answer by YDogan Monday, July 27, 2009 11:30 AM
    Friday, July 24, 2009 6:06 PM
  • Hi John and Steven,

    the type of exception is FormatException. As you can see in my test code above there i'am using the Exception. But there i have only the (FormatException) message

    'Error detail contains additional XML-Contents. Only a single Element is allowed'

    But this is not the exception that need. I have to have the access to the ServiceException, which contains the according message code that i need.

    I have checked the callstack, but there is only the message that i already mentioned. The service is throwing the following Exception:

    java.lang.Object
      extended byjava.lang.Throwable
          extended byjava.lang.Exception
              extended byjavax.xml.soap.SOAPException

    At the WCF-Side I'm not able to handle this. The Service hase a Class which reperesents this Message and contains the Code and the Message.

    What do you mean with intercepting call stack, do you have a piece of code?

    Monday, July 27, 2009 11:51 AM
  • Simply display the result of exc.ToString(). That will give us all the information.
    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Monday, July 27, 2009 3:03 PM
  • Hi John,

    This ist the Message in Original, but it is in German. There fore i have translated it in to eglish

    "Weitere XML-Inhalte sind im Fehlerdetailelement vorhanden. Nur ein einzelnes Element ist zulässig."
    ""Error detail contains additional XML-Contents. Only a single Element is allowed."

    and this ist the stactrace:

    Server stack trace:
       bei System.ServiceModel.Dispatcher.FaultFormatter.CreateFaultException(MessageFault messageFault, String action, Object detailObj, Type detailType, XmlDictionaryReader detailReader)
       bei System.ServiceModel.Dispatcher.FaultFormatter.CreateFaultException(MessageFault messageFault, String action)
       bei System.ServiceModel.Dispatcher.FaultFormatter.Deserialize(MessageFault messageFault, String action)
       bei System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
       bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       bei Efcom.Atradius.OrgSearchSR.OrgSearchSoapPort.getOrganisations(OrganisationSearchRequest request)
       bei Efcom.Atradius.ClientInterface.InterfaceForm.CallWsServiceCustomBinding(String pWebReference) in C:\Entwicklung\Attradius\WebClientAtradius\InterfaceForm.cs:Zeile 552.

    Monday, July 27, 2009 4:11 PM
  • Bitte:

    try
    {
        // Your code goes here
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.ToString());
    } 
    
    Ich spreche kein Deutsch, sondern "Google Translate" wird der Versuch in meinem Namen.

    So, really post the whole thing .
    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Monday, July 27, 2009 5:31 PM
  • Hi,

    this is the whole thin as youn want.



    Eine Ausnahme (erste Chance) des Typs "System.FormatException" ist in mscorlib.dll aufgetreten.

    System.FormatException: Weitere XML-Inhalte sind im Fehlerdetailelement vorhanden. Nur ein einzelnes Element ist zulässig.

    Server stack trace:

    bei System.ServiceModel.Dispatcher.FaultFormatter.CreateFaultException(MessageFault messageFault, String action, Object detailObj, Type detailType, XmlDictionaryReader detailReader)

    bei System.ServiceModel.Dispatcher.FaultFormatter.CreateFaultException(MessageFault messageFault, String action)

    bei System.ServiceModel.Dispatcher.FaultFormatter.Deserialize(MessageFault messageFault, String action)

    bei System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)

    bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

    bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)

    bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

    bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:

    bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

    bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

    bei Efcom.Atradius.OrgSearchSR.OrgSearchSoapPort.getOrganisations(OrganisationSearchRequest request)

    bei Efcom.Atradius.ClientInterface.InterfaceForm.CallWsServiceCustomBinding(String pWebReference) in C:\Entwicklung\Attradius\WebClientAtradius\InterfaceForm.cs:Zeile 552.

    Tuesday, July 28, 2009 6:53 AM
  •  

    Hi,

    This is the whole code as requested. Above the Exception Message in Origin. Do you like to have the proxy-class which is generated trough the wsdl?


    try
    {
        OrganisationList
    orgList = null;

     

        OrgSearchSoapPortChannel client = null;

     

        SecurityBindingElement security = SecurityBindingElement.CreateUserNameOverTransportBindingElement();

     

        BindingElementCollection bindingElements = new BindingElementCollection();

     

        HttpsTransportBindingElement httpsBindingElement = new HttpsTransportBindingElement();

     

        CustomTextMessageBindingElement textBindingElement = new CustomTextMessageBindingElement();

        bindingElements.Add(security);

        bindingElements.Add(

    new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8));

        bindingElements.Add(httpsBindingElement);

        bindingElements.Find<

    SecurityBindingElement>().IncludeTimestamp = false;

     

        CustomBinding binding = new CustomBinding(bindingElements);

     

        EndpointAddress pEndpointAddress = new EndpointAddress(pWebReference);

     

        ChannelFactory<OrgSearchSoapPortChannel> factory = new ChannelFactory<OrgSearchSoapPortChannel>(binding,   

        pEndpointAddress);

        factory.Credentials.CreateSecurityTokenManager();

        factory.Credentials.UserName.UserName =

    "UserName";

        factory.Credentials.UserName.Password =

    "password";

        client = factory.CreateChannel();

     

        OrgSearchRequest orgRequest = new OrgSearchRequest();

     

        OrganisationSearchRequest lOrganisationSearchRequest = new OrganisationSearchRequest();

        lOrganisationSearchRequest.getOrganisationsRequest = orgRequest;

        orgRequest.MaxOrg =

    "25";

        orgRequest.SearchType =

    "ALL";

     

        SearchOrganisation search = null;

     

        if (search == null)

            search =

    new SearchOrganisation();

     

        NameAddress nameAddress = new NameAddress();

     

        Country country = new Country();

        country.Item =

    "DEU";

        nameAddress.Country = country;

     

        Address adress = new Address();

        adress.Street =

    new Street();

        adress.Street.Items =

    new string[] { "" };

        adress.City =

    "";

        nameAddress.Address = adress;

     

        Name name = new Name();

        name.Items =

    new string[] {"dkjfhdkjhfkdfhskd"}; //findet keine Treffer

        nameAddress.Name = name;

        search.NameAddress = nameAddress;

        orgRequest.SearchOrganisation = search;

     

       orgList = client.getOrganisations(lOrganisationSearchRequest).getOrganisationsReturn;
    }
    catch (Exception exp)
    {
       

        System.Diagnostics.

    Debug.WriteLine(exp.ToString());

     


    }

     

     

    Tuesday, July 28, 2009 7:11 AM
  • Thanks. The client proxy code will not be required.

    I can now see that this occurs while processing the response from the client call. The client has returned a SOAP Fault, and WCF is attempting to process it. However, it appears that this fault has more than one XML element in its Details element, which is not allowed.

    You'll need to turn on message tracing in the client, or else watch the network when this happens using Fiddler or something like it. You'll want to see exactly what the client sends back.

    It might also be possible to see the problem in the WSDL. If you can see which faults are specified for this operation, and then post here the messages referred to by the fault elements, we might see what the service intends to send back. For instance, it's possible we'll see the fault uses multiple message parts, which I believe is not permitted.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Tuesday, July 28, 2009 2:39 PM
  • Hi John,

    I'm using the Fiedler already for tracing. This is wat I'm see in Fiedler:


    HTTP/1.1 500 Internal Server Error

    Date: Tue, 28 Jul 2009 15:03:12 GMT

    Server: IBM_HTTP_Server

    Connection: close

    Content-Type: text/xml; charset=utf-8

    Content-Language: en-GB

    Content-Length: 819

    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.generalException</faultcode><faultstring></faultstring><detail><ns1:WSException xmlns:ns1="http://atradius.com/services/organisationsearch/2006_03_17/exception"><errorCode>S001</errorCode><errorDescription>No organisations found.</errorDescription></ns1:WSException><ns2:exceptionName xmlns:ns2="http://xml.apache.org/axis/">com.atradius.services.organisationsearch._2006_03_17.exception.WSException</ns2:exceptionName><ns3:hostname xmlns:ns3="http://xml.apache.org/axis/">bc33</ns3:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>


    This is what i exactly ecpect to response, because of ErrorCode und the description. Instead a FormatException is thrown with the message, which i mentioned above.


    Here is the exception part within the WSDL:

    <

     

    wsdl:message name="OrganisationSearchError">

        <

     

    wsdl:part name="OrganisationSearchException" element="ex:WSException"/>

    </

     

    wsdl:message>

    <

     

    wsdl:portType name="OrgSearchSoapPort">

        <

     

    wsdl:operation name="getOrganisations">

            <

     

    wsdl:input name="OrganisationSearchRequest" message="impl:getOrganisationsRequest"/>

            <

     

    wsdl:output name="OrganisationSearchResponse" message="impl:getOrganisationsResponse"/>

            <

     

    wsdl:fault name="OrganisationSearchErrorMessage" message="impl:OrganisationSearchError"/>

        </

     

    wsdl:operation>

    </

     

    wsdl:portType>

    <

     

    wsdl:binding name="OrgSearchSoapBinding" type="impl:OrgSearchSoapPort">

        <

     

    soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

        <

     

    wsdl:operation name="getOrganisations">

            <

     

    soap:operation soapAction="getOrganisations"/>

            <

     

    wsdl:input name="OrganisationSearchRequest">

                <

     

    soap:body use="literal"/>

           </

     

    wsdl:input>

           <

     

    wsdl:output name="OrganisationSearchResponse">

               <

     

    soap:body use="literal"/>

           </

     

    wsdl:output>

        <

     

    wsdl:fault name="OrganisationSearchErrorMessage">

            <

     

    soap:fault name="OrganisationSearchErrorMessage" use="literal"/>

        </

     

    wsdl:fault>

    </

     

    wsdl:operation>

    </

     

    wsdl:binding>


    Coud you see anything wrong in my code? I hope with tis additional information you are able to see what the real problem is.
    I assume some thin is still missing in my custom binding, which leads to the problem.

    Tuesday, July 28, 2009 3:19 PM
  • This is beginning to look like a bug in WCF. It looks like it should accept the multiple elements within the Detail element of the fault. The XML Schema for that element is:

      <xs:element name="Fault" type="tns:Fault" />
      <xs:complexType name="Fault" final="extension" >    
        <xs:sequence>
          <xs:element name="faultcode" type="xs:QName" />
          <xs:element name="faultstring" type="xs:string" />
          <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
          <xs:element name="detail" type="tns:detail" minOccurs="0" />      
        </xs:sequence>
      </xs:complexType>
    
      <xs:complexType name="detail">
        <xs:sequence>
          <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
        </xs:sequence>
        <xs:anyAttribute namespace="##any" processContents="lax" /> 
      </xs:complexType>
    

    As you can see, it should be accepting any number of arbitrary elements.

    To help narrow this down (and to help prepare for a bug report), I'd like a few things:

    1. Can you edit your post to clean up the XML? The XML I posted above wasd done using the "Insert code block" button on the editor toolbar - the furthest right.
    2. Can you include the XML Schema describing ex:WSException? The fault is defined to match that type, so let's see that type.
    3. I would like to see the portion of the client proxy that corresponds to the fault. I believe the proxy should be defining a type OrganisationSearchException. That's what I'd like to see. In particular, I'd like to know if it has spaces for all three elements.
    A good experiment (for someone with more available time than I now have), would be to create a dummy service that declares a fault with three parts and then returns that fault when called. It would be interesting to see whether the proxy properly matches the fault, and whether a FormatException is thrown when the fault is received.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Tuesday, July 28, 2009 6:03 PM
  • Hi John,

    thanks for your effords.

    1. Here is the WSException Scheme:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://atradius.com/services/exception/_2006_12_15/exception" targetNamespace="http://atradius.com/services/exception/_2006_12_15/exception" elementFormDefault="qualified" attributeFormDefault="qualified">
    	<xs:complexType name="WSException">
    		<xs:sequence>
    			<xs:element name="errorCode" type="xs:string" nillable="true"/>
    			<xs:element name="errorDescription" type="xs:string" nillable="true"/>
    			<xs:element name="serverErrorReferenceToken" type="xs:string" nillable="true"/>
    			<xs:element name="values" type="ex:arrayWrapper" nillable="true"/>
    		</xs:sequence>
    	</xs:complexType>
    	<xs:complexType name="arrayWrapper">
    		<xs:sequence>
    			<xs:element name="value" type="xs:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
    		</xs:sequence>
    	</xs:complexType>
    </xs:schema>

    2. The WSD-Structure:

    <wsdl:message name="OrganisationSearchError">
    	<wsdl:part name="OrganisationSearchException" element="ex:WSException"/>
    </wsdl:message>
    <wsdl:portType name="OrgSearchSoapPort">
    	<wsdl:operation name="getOrganisations">
    		<wsdl:input name="OrganisationSearchRequest" message="impl:getOrganisationsRequest"/>
    		<wsdl:output name="OrganisationSearchResponse" message="impl:getOrganisationsResponse"/>
    		<wsdl:fault name="OrganisationSearchErrorMessage" message="impl:OrganisationSearchError"/>
    	</wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="OrgSearchSoapBinding" type="impl:OrgSearchSoapPort">
    	<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    	<wsdl:operation name="getOrganisations">
    		<soap:operation soapAction="getOrganisations"/>
    		<wsdl:input name="OrganisationSearchRequest">
    			<soap:body use="literal"/>
    		</wsdl:input>
    		<wsdl:output name="OrganisationSearchResponse">
    			<soap:body use="literal"/>
    		</wsdl:output>
    		<wsdl:fault name="OrganisationSearchErrorMessage">
    			<soap:fault name="OrganisationSearchErrorMessage" use="literal"/>
    		</wsdl:fault>
    	</wsdl:operation>
    </wsdl:binding>
    3. Portion of Proxy-Code that corresponds to the fault.

        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
        [System.SerializableAttribute()]
        [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
        [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
        public partial class WSException : object, System.Xml.Serialization.IXmlSerializable, System.ComponentModel.INotifyPropertyChanged {
            
            private System.Xml.XmlNode[] nodesField;
            
            private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("WSException", "http://atradius.com/services/organisationsearch/2006_03_17/exception");
            
            public System.Xml.XmlNode[] Nodes {
                get {
                    return this.nodesField;
                }
                set {
                    if ((object.ReferenceEquals(this.nodesField, value) != true)) {
                        this.nodesField = value;
                        this.RaisePropertyChanged("Nodes");
                    }
                }
            }
            
            public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            
            public void ReadXml(System.Xml.XmlReader reader) {
                this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
            }
            
            public void WriteXml(System.Xml.XmlWriter writer) {
                System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
            }
            
            public System.Xml.Schema.XmlSchema GetSchema() {
                return null;
            }
            
            public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas) {
                System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
                return typeName;
            }
            
            protected void RaisePropertyChanged(string propertyName) {
                System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
                if ((propertyChanged != null)) {
                    propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
                }
            }
        }


    In case it is a bug in WCF how do I get a fix for that problem?

    I hope you cam simulate the whole situation.

    May be I can ask the service provider, if you like to have the complete structure of the WSDL?

    Wednesday, July 29, 2009 8:14 AM
  • The way to report bugs is on http://connect.microsoft.com/visualstudio/.

    The thing is, I'm seeing several bugs or at least issues, here:
    1. I do not understand why WSException is being translated into the code you just posted. Where's errorCode?
    2. It's not clear to me why the receipt of this fault should throw a FormatException instead of ignoring the extra elements
    3. When I experimented and tried to create a fault with multiple parts in the message, WCF silently ignored the fault entirely.
    Finally, I think there may be a bug on the IBM side. The fault message only describes WSException, not the other two elements. I don't believe it should be sending them without describing them in the WSDL.

    It turns out that I'm running low on time to deal with this. I'd like to have a nice package to send to Connect to get these issues addressed. If I don't get that done in the next couple of days, then I suggest you do it yourself.

    It will help if I can get the entire WSDL. Do make it clear that I'm an MVP, and that MVPs do not work for Microsoft. If you'd like to email me at johnwsaundersiii@live.com, I can send the service provider proof of who I am, if that will help them.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Wednesday, July 29, 2009 1:29 PM
  • Hi,
    I have exactly the same problem, did you find a a solution yet or is it a bug?
    Thanks for your reply
    W.
    Thursday, October 01, 2009 9:47 AM
  • I too have this problem.  My company works with a LARGE banking concern that has web services using .ASMX and are not likely to change anytime soon.  They produce SoapException errors base on application level error such as client provisioning (business rule) to services that try to connect.  For example the gateway web service connect into a number of bank networks. If the caller is provisioned in one bank network but not in another and attempts to connect to the "out of bound" bank it generates an application level SoapException.

    We have NO - None - Not a bit, zilch control over what we get at the client when it comes to the SoapException content.  Fortunately they at least follow the SoapException standards.

    From fiddler this is what we get... sanitized

    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <soap:Fault>
    <faultcode>soap:Client</faultcode>
    <faultstring>System.Web.Services.Protocols.SoapException: Provisioning violation: unknown IP address. IP address [xxxxxxx] is not recognized or client application is not a licensed subscriber to RTMS</faultstring>
    <faultactor>GetPurseInfo</faultactor>
    <detail>
    <faulttype>Data</faulttype>
    <errorlist>
    <field errorcode="Client" errortype="Provision">[127.0.0.1]</field>
    </errorlist>
    </detail>
    </soap:Fault>
    </soap:Body>
    </soap:Envelope>

    This is a sample from the web service provider's API document of what we should be receiving for a SoapException...

    <?xml version="1.0" encoding="utf-8"?>

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

     

    <soap:Body>

                    <soap:Fault>

                                    <faultcode>soap:Client</faultcode>

                                    <faultstring>Provisioning violation: unknown IP address. IP address [127.0.0.1] is not recognized or client application is not a licensed subscriber to RTMS.</faultstring>

                                    <faultactor> Ts2IPService</faultactor>

                                    <detail>

                                                    <faulttype>Data</faulttype>

                                                    <errorlist>

                                                                    <field errorcode="Client" errortype="Provision">127.0.0.1</field>

                                                    </errorlist>

                                    </detail>

                    </soap:Fault>

    </soap:Body>

    </soap:Envelope>

    I would say from the empirical response and the expected response that something is WRONG in the WCF FaultException handler.

    Here is a snipet of my exception handler...

     

    catch (FaultException faultException) //Catches the SOAP exceptions thrown by web services
    {
       string faultString = faultException.Message;
       string faultNameSpace = faultException.Code.Namespace;
       string faultCode = faultException.Code.Name;

     

       if (faultException.Code.SubCode != null)
       {
          string faultSubCode = faultException.Code.SubCode.Name;
          string faultSubCodeValue = faultException.Code.SubCode.ToString();
       }

     

    ...

    ...

    My expectation was that "SubCode" would contain the nested XML within the "detail" section. It is always null.

    The SoapException class exposes a "detail" node by convention.
    The FaultException class does NOT surface the "detail" therefore all information in "detail" is not accessable.

    I am using .NET 3.5 sp1 so if there is a bug it is still not fixed.

    In our case we NEED the data in the detail to properly handle the exceptions.  The "errorcode" is naturally very important as is the type and the acutal value.

    I have hunted for days now for a solution short of dumping WCF. We are on a short fuse and need a fix.

    Larry Aultman

    Sunday, November 01, 2009 3:54 AM
  • I found a way at least to get to the "detail' here...

    However I have a problem with this method as well.  It seems to only return the FIRST element of the "detail" which is not very useful.

    I need ALL the detail section.

    Still working on a solution.  We could use a little guidance here Microsoft!

    Here is some test code below.  Note everything from this statement down doesn't work so ignore:
    if (faultException.Code.SubCode != null)


    catch (FaultException faultException)	//Catches the SOAP exceptions thrown by Tsys web services
    {
    //string myFaultDetails = "";
    XmlElement faultDetails = null;
    MessageFault messageFault = faultException.CreateMessageFault();
    
    if (messageFault.HasDetail)
    {
    	System.Xml.XmlDocument doc = new
    	System.Xml.XmlDocument();
    	System.Xml.XmlNode node = doc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
    	//It is easier to manage XML with LINQ so get the "detail" node just created above into a LINQ class
    	XElement detail = GetXElement(node);
    	faultDetails = messageFault.GetDetail<XmlElement>();
    	XElement xElement = GetXElement(messageFault.GetDetail<XmlElement>());
    	detail.Add(xElement);
    	string faultTypeName = xElement.Name.LocalName;
    	string faultType = xElement.Value;
    }
    string faultString = faultException.Message;
    string faultNameSpace = faultException.Code.Namespace;
    string faultCode = faultException.Code.Name;
    if (faultException.Code.SubCode != null)
    {
    	string faultSubCode = faultException.Code.SubCode.Name;
    	string faultSubCodeValue = faultException.Code.SubCode.ToString();
    }
    if (faultException.Action != null)
    {
    	string faultAction = faultException.Action;
    }
    this.richTextBox1.Text = faultDetails.ToString();
    
    Sunday, November 01, 2009 2:59 PM
  • Larry, did you report this as a bug on Connect? Did you contact Microsoft support?

    I recommend you do both.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Sunday, November 01, 2009 4:32 PM
  • Yep,
    Bug ID: 507379

    Haven't heard anything yet from support.
    I take it you haven't seen anything on a resolution judging from your response.  I checked last night and it is exactly the same in .NET 4.0

    You would think that somebody has already addressed this issue somewhere.  I talked to another MVP today and they are not going to use WCF in a major project with tens of millions of transactions because of this and a few related issues.

    I have yet to have a health or finance partner that uses WCF on their web services.

    "Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE"

    NEW is the keyword.  Our clients are health, government, and finance.  Not exactly cutting edge ;)


    Larry
    Monday, November 02, 2009 3:52 AM
  • If by "bug id", you are referring to a Connect issue, then please post the URL of the issue so that we can vote on its importance.

    You might also wish to consider that WCF is now three years old, which is no longer "cutting edge". Also, the vast majority of developers are able to use it without encountering the problem you have encountered.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Monday, November 02, 2009 6:29 AM
  • Please vote on the importance of this issue at:
    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=507379

    I agree with you John that WCF is now three years old and no longer cutting edge.  However banks, government, and healthcare industries are woefully BEHIND the curve.  There is very little incentive for them to "upgrade" many are still using .NET 1.1 and can afford to pay the "labor" cost to avoid the "risk" to the business.

    So the "risk/reward" is not in my favor of seeing any NEW web services that would include WCF for a long time.  Thus this issue is a real one for those of us who must try and make systems work together (forget interoperability) with a comfortable level of dependability.

    Larry
    Monday, November 02, 2009 2:21 PM
  • This issue would be solved easily even in this situation if the developers could implement a soap detail with an "envelope" (node) inside the standard "detail" section of the fault that contained all of their details.  That would be a breaking change though for them.

    For example:
    some xml...
       <detail>
         <applevelfault>
           <error1>1</error1>
           <error2>phone</error2>
         </applevelfault>
       </detail>

    In my example the "applevelfault" becomes the envelope of the error detail and the existing Microsoft code would return the entire item in the detail.  I suspect that this was the intention of the soap specification designers.  However that is not what the implementers have done.  Instead they interpret the soap specification as "detail" is the envelope and the handler should return the "detail".  I think that Microsoft sould expose the "detail".  It would not break any existing implmentations.

    Larry

    Monday, November 02, 2009 2:31 PM
  • Larry, this is not a bug. I recommend that you look at using the MessageFault.CreateReaderAtDetailContents method:

        try
        {
            var errorsService = new ErrorsAndWarningsSoapClient("ErrorsAndWarningsSoap");
            bool hasWarnings;
            string[] warnings;
            var returnData = errorsService.DoWork(out hasWarnings, out warnings);
        }
        catch (FaultException e)
        {
            var fault = e.CreateMessageFault();
            using (var reader = fault.GetReaderAtDetailContents())
            {
                while (reader.Read())
                {
                    // Do what you like with the reader
                }
            }
        }

    I have tried this, and have retrieved the entire contents of the detail element.

    As a result, I have voted your issue as not important, and have added the above code as a workaround.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Monday, November 02, 2009 4:19 PM
  • Thanks John,

    Trying your workaround.  I hope this helps others that I know have the same issue!

    Larry
    Monday, November 02, 2009 5:28 PM
  • Well John there still seems to be issues so you should go back and revisit your vote.  Your code snip above does infact return the data content however as I initially stated above the attributes also are necessary to be able to properly decode the errors being thrown.  The XML in the provided example is valid but the workaround does not pick up the attributes and their associated values only the actual "content".

    I am still trying to get valid XML so I may parse it in its entirity.

    So in my book it is still a bug when I can't get the data back that is in the detail - ALL OF IT.

    I really appreciate your taking time to look into the issue and I hope you might have other ideas. I am still searching.  If I could somehow just get the detail as an XML element I think it would pull all its children too.

    Larry

    Tuesday, November 03, 2009 3:47 AM
  • If I understand you correctly, your only remaining issue is that you cannot retrieve the attributes on the detail element. I cannot see that this is a major issue, since there is no way, with ASMX services, to place any attributes on the Detail element.

    In any case, I suggest you create a service that reproduces this issue, and a small client which illustrates that the attributes cannot be retrieved. I suggest that you then create a new thread here and post that code. The subject of this thread no longer reflects the problem you're having, and the thread is now quite long. You have no problem "catching a SoapException", only in retrieving attributes from the detail element.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Tuesday, November 03, 2009 2:04 PM
  • You can retrieve the entire Fault element in an XmlDocument as follows:

    catch (FaultException e)
    {
        var fault = e.CreateMessageFault();
        XmlDocument doc = new XmlDocument();
        var nav = doc.CreateNavigator();
        using (var writer = nav.AppendChild())
        {
            fault.WriteTo(writer, EnvelopeVersion.Soap11);
        }
    }
    


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    • Proposed as answer by J Larry Aultman Wednesday, November 04, 2009 1:12 AM
    Tuesday, November 03, 2009 2:54 PM
  • I agree with you John I am now catching the exception I am just not able to retrieve the innerXML of the detail.  You are also correct that you cannot add attributes to the "detail" element in asmx.  The value part of the detail is the innerXML which I can't get. The child elements of the detail element can and do have attributes and also values.  Your solution does return the "value" part but not the element attributes.  I wish the web service developers had not done it this way but there is nothing I can do about it.  It has been in service for some years now and not likely to change as it will break a lot of working code. 

    I do have a sample asmx project that generates the soapexception fault and I have a sample client that is catching the soapexception. I am as you said just now trying to get the detail content value.

    So I will take your suggestion and start a new thread and post it back here so that others will able to continue the thought.

    Thanks,

    Larry

    Do you and any suggestion for a thread title that will be useful for searching? I am thinking, "Unable to Extract SoapException Detail."
    Tuesday, November 03, 2009 3:07 PM
  • I was mistaken about not being able to supply attributes with ASMX. You can supply both, because you can set the Detail property to include an entire element, including attributes.

    The code I just posted above, using fault.WriteTo, retrieves the entire fault, including the entire detail element, which includes any attributes on that element:

    <Fault xmlns="http://schemas.xmlsoap.org/soap/envelope/">
        <faultcode xmlns:a="http://schemas.xmlsoap.org/soap/envelope/" xmlns="">a:Server</faultcode>
        <faultstring xmlns="">System.Web.Services.Protocols.SoapException: An error occurred
       at WebService1.ErrorsAndWarnings.DoWork(Boolean&amp; hasWarnings, List`1&amp; warningMessages) in C:\Users\John Saunders\Documents\MVP\projects\WebServices\GeneralSoln\WebService1\ErrorsAndWarnings.asmx.cs:line 40</faultstring>
        <faultactor xmlns="">http://tempuri.org/WebService1/ErrorsAndWarnings/DoWork</faultactor>
        <detail attr1="2" attr2="2" xmlns="">
            <ErrorFault xmlns="http://tempuri.org/WebService1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <ErrorMessages>
                    <string>Message 1</string>
                    <string>Message 2</string>
                </ErrorMessages>
            </ErrorFault>
            <Additional>1</Additional>
        </detail>
    </Fault>

    With these workarounds, I no longer see any problems at all. Please let me know if there is anything you need to do that you cannot now do.
    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Tuesday, November 03, 2009 4:34 PM
  • Thanks John,

    I greatly appreciate your efforts.  I created a complete web service/test client to exercise the various solutions.  Your last post does allow complete access to all the details which is great!

    I posted your workaround on the connection site.

    The only shame is that it took days to figure this out.  Oh well, at least I have the attention of the vendor now, maybe we can move them to WCF.

    Your solution is compact and complete! Very cool!  I think I will post the solution project on codeproject.com. I certainly will give proper credit.

    Larry
    Wednesday, November 04, 2009 1:12 AM
  • Thanks, Larry, that's great. Community in Action!

    Be sure to post the URL to the solution on the Connect site as well.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Wednesday, November 04, 2009 3:17 AM
  • Here is link to a codeproject.com article detailing the solution with source code.

    http://www.codeproject.com/KB/webservices/SoapClientTest.aspx 

    Larry
    Sunday, November 08, 2009 2:01 AM
  • Hi,

    it is long time ago that i reported this problem.

    It seems that rhere is a possibility to make a work around as you did.

    I was also able to solve this in my own with a work around.

    I just created a Static Class in may Reference class.

    [System.SerializableAttribute()]
        [System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
        [System.Xml.Serialization.XmlRootAttribute(IsNullable = false)]
        public static class WSEFaultException
        {
            static string mCode = "";
            static string mCodeText = "";
    
            public static void SetExceptionCode(string pCode)
            {
                mCode = pCode;
            }
    
            public static void SetExceptionDescription(string pDescription)
            {
                mCodeText = pDescription;
            }
    
            public static string ExceptionCode()
            {
                return mCode;
            }
    
            public static string ExceptionDescription()
            {
                return mCodeText;
            }
        }

    and then assign the arrcode and error description to the attributes of this class.

    afterwords it is possible to get the code and the description from the static class.

    here is the part where a assign the code and the description to the static class

        //[System.Diagnostics.DebuggerStepThroughAttribute()]
        //[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
        [System.Runtime.Serialization.DataContractAttribute(Name="WSException", Namespace="http://atradius.com/services/exception/_2006_12_15/exception")]
        [System.SerializableAttribute()]
        public partial class WSException : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
            
            [System.NonSerializedAttribute()]
            private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
            
            private string errorCodeField;
            
            private string errorDescriptionField;
            
            private string serverErrorReferenceTokenField;
            
            private Efcom.Atradius.CoverDecisionSR.arrayWrapper valuesField;
            
            [global::System.ComponentModel.BrowsableAttribute(false)]
            public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
                get {
                    return this.extensionDataField;
                }
                set {
                    this.extensionDataField = value;
                }
            }
            
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
            public string errorCode {
                get {
                    return this.errorCodeField;
                }
                set {
                    if ((object.ReferenceEquals(this.errorCodeField, value) != true)) {
                        this.errorCodeField = value;
                        WSEFaultException.SetExceptionCode(this.errorCodeField);
                        this.RaisePropertyChanged("errorCode");
                    }
                }
            }
            
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
            public string errorDescription {
                get {
                    return this.errorDescriptionField;
                }
                set {
                    if ((object.ReferenceEquals(this.errorDescriptionField, value) != true)) {
                        this.errorDescriptionField = value;
                        WSEFaultException.SetExceptionDescription(this.errorDescriptionField);
                        this.RaisePropertyChanged("errorDescription");
                    }
                }
            }
            
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
            public string serverErrorReferenceToken {
                get {
                    return this.serverErrorReferenceTokenField;
                }
                set {
                    if ((object.ReferenceEquals(this.serverErrorReferenceTokenField, value) != true)) {
                        this.serverErrorReferenceTokenField = value;
                        this.RaisePropertyChanged("serverErrorReferenceToken");
                    }
                }
            }
            
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
            public Efcom.Atradius.CoverDecisionSR.arrayWrapper values {
                get {
                    return this.valuesField;
                }
                set {
                    if ((object.ReferenceEquals(this.valuesField, value) != true)) {
                        this.valuesField = value;
                        this.RaisePropertyChanged("values");
                    }
                }
            }
            
            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));
                }
            }
        }

     

    Monday, April 12, 2010 12:17 PM
  • I see that you are trying to develop WCF client for Atradius web service. I have the same exact problem right now. Can't get working WCF client, and I have the same behavior for the WSE3 client.
    How did you managed your problem?

    I'm going mad!

     

    Thanks

    • Marked as answer by YDogan Thursday, January 20, 2011 9:25 AM
    • Unmarked as answer by YDogan Thursday, January 20, 2011 9:25 AM
    Monday, January 17, 2011 2:45 PM
  • Hi,

    i had some problems reagrding Soap-Exceptions, but i was able to solve them.

    What ist your real problem?

    Thursday, January 20, 2011 9:29 AM
  • Hey,

    i have to implement atradius connect.

    its impossible for me. is it possible to get some full code ?

    just to see how it works.

    PLEASE.

    i will send 30$ per paypal if someone replys.

    Best would be PHP, but c# would be okay too.

    Thank you very much

    • Proposed as answer by EpicDevZ Thursday, November 21, 2013 2:59 PM
    • Unproposed as answer by EpicDevZ Thursday, November 21, 2013 2:59 PM
    Thursday, November 21, 2013 2:58 PM