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:operation 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]));
}
}
}
pgarg4@csc.com - 16 Mar 2006 12:03 GMT
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.
rodmcleay - 17 Nov 2006 06:31 GMT
> *In Visual Studio .NET, I try to generate C# proxy class from WSDL,
> and
[quoted text clipped - 163 lines]
> }
> } *
John Saunders - 17 Nov 2006 12:36 GMT
>> *In Visual Studio .NET, I try to generate C# proxy class from WSDL,
>> and
[quoted text clipped - 10 lines]
>>
>> 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