cannot generate C# exception code corresponds to <wsdl:fault> element

Discussion in 'ASP .Net Web Services' started by Steve, Feb 24, 2006.

  1. Steve

    Steve Guest

    In Visual Studio .NET, I try to generate C# proxy class from WSDL, and
    the WSDL file has <wsdl:fault> element. I expect the generated proxy
    code should have the exception code that corresponds to <wsdl:fault>
    element, but it doesn't have any.

    I did some research and found out WSDL description generated by a .NET
    Web service does not contain any wsdl:fault or soapbind:fault elements.
    I am not sure if this is true, and not sure if VS.NET supports
    exception code generation from <wsdl:fault> element. Is that true?

    any ideas? please advise.

    thanks!!

    =============================

    Here's the WSDL and generated C# proxy code for references:


    <?xml version="1.0" encoding="utf-8"?>
    <definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:s0="http://tempuri.org/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    targetNamespace="http://tempuri.org/"
    xmlns="http://schemas.xmlsoap.org/wsdl/">
    <types>
    <s:schema elementFormDefault="qualified"
    targetNamespace="http://tempuri.org/">
    <s:element name="sum">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="1" maxOccurs="1" name="a"
    type="s:int" />
    <s:element minOccurs="1" maxOccurs="1" name="b"
    type="s:int" />
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="sumResponse">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="1" maxOccurs="1" name="sumResult"
    type="s:int" />
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="sumException">
    <s:complexType>
    <s:sequence>
    <s:element name="errorMessage" type="s:string" />
    </s:sequence>
    </s:complexType>
    </s:element>
    </s:schema>
    </types>
    <message name="sumSoapIn">
    <part name="parameters" element="s0:sum" />
    </message>
    <message name="sumSoapOut">
    <part name="parameters" element="s0:sumResponse" />
    </message>
    <message name="sumSoapFault">
    <part name="parameters" element="s0:sumException" />
    </message>
    <portType name="Service1Soap">
    <operation name="sum">
    <input message="s0:sumSoapIn" />
    <output message="s0:sumSoapOut" />
    <fault message="s0:sumSoapFault" />
    </operation>
    </portType>
    <binding name="Service1Soap" type="s0:Service1Soap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
    style="document" />
    <operation name="sum">
    <soap:eek:peration soapAction="http://tempuri.org/sum"
    style="document" />
    <input>
    <soap:body use="literal" />
    </input>
    <output>
    <soap:body use="literal" />
    </output>
    </operation>
    </binding>
    <service name="Service1">
    <port name="Service1Soap" binding="s0:Service1Soap">
    <soap:address location="http://localhost/sumws1/Service1.asmx" />
    </port>
    </service>
    </definitions>

    =============================

    //------------------------------------------------------------------------------
    // <autogenerated>
    // This code was generated by a tool.
    // Runtime Version: 1.1.4322.573
    //
    // Changes to this file may cause incorrect behavior and will be
    lost if
    // the code is regenerated.
    // </autogenerated>
    //------------------------------------------------------------------------------

    //
    // This source code was auto-generated by Microsoft.VSDesigner, Version
    1.1.4322.573.
    //
    namespace wstest.WebReference {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using System.Web.Services;


    /// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]

    [System.Web.Services.WebServiceBindingAttribute(Name="Service1Soap",
    Namespace="http://tempuri.org/")]
    public class Service1 :
    System.Web.Services.Protocols.SoapHttpClientProtocol {

    /// <remarks/>
    public Service1() {
    this.Url = "http://localhost/wstest/Service1.asmx";
    }

    /// <remarks/>

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/sum",
    RequestNamespace="http://tempuri.org/",
    ResponseNamespace="http://tempuri.org/",
    Use=System.Web.Services.Description.SoapBindingUse.Literal,
    ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public int sum(int a, int b) {
    object[] results = this.Invoke("sum", new object[] {
    a,
    b});
    return ((int)(results[0]));
    }

    /// <remarks/>
    public System.IAsyncResult Beginsum(int a, int b,
    System.AsyncCallback callback, object asyncState) {
    return this.BeginInvoke("sum", new object[] {
    a,
    b}, callback, asyncState);
    }

    /// <remarks/>
    public int Endsum(System.IAsyncResult asyncResult) {
    object[] results = this.EndInvoke(asyncResult);
    return ((int)(results[0]));
    }
    }
    }
     
    Steve, Feb 24, 2006
    #1
    1. Advertising

  2. Steve

    Guest

    Re: cannot generate C# exception code corresponds to < ...

    Hi,
    Your are absolutely right. I encountered the same problem, and reached on the same conclusion, what ur suggesting.

    Exception related code can not be generated for wsdl , c#,vb.net related files.
    Bydefault, when we create client proxy or Server stub from wsdl file(which is having fault tag), it dosent any different peiece of code related to exception in code files.

    ---
    Posted via www.DotNetSlackers.com
     
    , Mar 16, 2006
    #2
    1. Advertising

  3. "rodmcleay" <> wrote in message
    news:...
    >
    > Steve wrote:
    >> *In Visual Studio .NET, I try to generate C# proxy class from WSDL,
    >> and
    >> the WSDL file has <wsdl:fault> element. I expect the generated proxy
    >> code should have the exception code that corresponds to <wsdl:fault>
    >> element, but it doesn't have any.
    >>
    >> I did some research and found out WSDL description generated by a
    >> .NET
    >> Web service does not contain any wsdl:fault or soapbind:fault
    >> elements.
    >> I am not sure if this is true, and not sure if VS.NET supports
    >> exception code generation from <wsdl:fault> element. Is that true?
    >>
    >> any ideas? please advise.


    It is true. .NET does not support generation of wsdl:fault elements, nor
    will it generate exceptions corresponding to wsdl:fault elements it finds
    during proxy generation.

    In this case, the Java world has it over .NET. I used IBM Rational
    Application Developer product (an eval) and was able to trivially create a
    Java client for my web service. It came complete with exceptions that not
    only matched my wsdl:fault elements, but they also properly deserialized the
    <details> element in the fault into properties on the exception.

    Why .NET can't do this, I don't know.

    John
     
    John Saunders, Nov 17, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Huygens

    How to have a "fault" element in generated WSDL?

    Arnold Huygens, Aug 2, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    182
  2. Generate verbose WSDL from WSDL with imports

    , Apr 26, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    226
  3. Nick Locke

    wsdl.exe not creating class for fault element

    Nick Locke, Oct 21, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    446
    John Saunders
    Oct 21, 2006
  4. Robbo

    No "fault" element in generated WSDL

    Robbo, Aug 21, 2007, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    265
    John Saunders [MVP]
    Aug 22, 2007
  5. Jai
    Replies:
    7
    Views:
    128
Loading...

Share This Page