Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Define Correspond Fault for the Soap Exception in the WSDL

Reply
Thread Tools

Define Correspond Fault for the Soap Exception in the WSDL

 
 
huohaodian@gmail.com
Guest
Posts: n/a
 
      08-05-2008
Hi,

I am planning to use a custom wsdl for my web service, it seems
that the SoapException class provides nice and easy way to handle soap
exception on the server side. Corresponding to the associated fault
definition in the wsdl, how should I define the fault element that
corresponds to the exception SoapException may be raised from server
with message, code, actor and detail?

Thanks in advance.
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      08-05-2008
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I am planning to use a custom wsdl for my web service, it seems
> that the SoapException class provides nice and easy way to handle soap
> exception on the server side. Corresponding to the associated fault
> definition in the wsdl, how should I define the fault element that
> corresponds to the exception SoapException may be raised from server
> with message, code, actor and detail?


You simply define the structure of the detail section using XML Schema.
Then, refer to it in the <wsdl:message> element that defines the fault
message. Refer to the fault message in the <wsdl:fault> section using the
type attribute.

Then, all you have to do is construct an instance of your fault detail and
provide it to the SoapException constructor.

I don't have time to find or create an example today, but let me know if
you're still stuck after this and I'll try to make time.

--
John Saunders | MVP - Connected System Developer

 
Reply With Quote
 
 
 
 
huohaodian@gmail.com
Guest
Posts: n/a
 
      08-06-2008
On Aug 5, 4:01*pm, "John Saunders" <(E-Mail Removed)> wrote:
> <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > Hi,

>
> > * I am planning to use a custom wsdl for my web service, it seems
> > that the SoapException class provides nice and easy way to handle soap
> > exception on the server side. Corresponding to the associated fault
> > definition in the wsdl, how should I define the fault element that
> > corresponds to the exception SoapException may be raised from server
> > with message, code, actor and detail?

>
> You simply define the structure of the detail section using XML Schema.
> Then, refer to it in the <wsdl:message> element that defines the fault
> message. Refer to the fault message in the <wsdl:fault> section using the
> type attribute.
>
> Then, all you have to do is construct an instance of your fault detail and
> provide it to the SoapException constructor.
>
> I don't have time to find or create an example today, but let me know if
> you're still stuck after this and I'll try to make time.
>
> --
> John Saunders | MVP - Connected System Developer



Thank you so much John.

I am still struggling... is it possible you could give me a little
sample?

Thanks again.
 
Reply With Quote
 
huohaodian@gmail.com
Guest
Posts: n/a
 
      08-07-2008
On Aug 5, 4:01*pm, "John Saunders" <(E-Mail Removed)> wrote:
> <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > Hi,

>
> > * I am planning to use a custom wsdl for my web service, it seems
> > that the SoapException class provides nice and easy way to handle soap
> > exception on the server side. Corresponding to the associated fault
> > definition in the wsdl, how should I define the fault element that
> > corresponds to the exception SoapException may be raised from server
> > with message, code, actor and detail?

>
> You simply define the structure of the detail section using XML Schema.
> Then, refer to it in the <wsdl:message> element that defines the fault
> message. Refer to the fault message in the <wsdl:fault> section using the
> type attribute.
>
> Then, all you have to do is construct an instance of your fault detail and
> provide it to the SoapException constructor.
>
> I don't have time to find or create an example today, but let me know if
> you're still stuck after this and I'll try to make time.
>
> --
> John Saunders | MVP - Connected System Developer


I have created structure for the detail section

<s:complexType name="detail">
<s:sequence>
<s:element name="ErrorCode" type="s:int"/>
<s:element name="Message" type="s:string"/>
</s:sequence>
</s:complexType>

then added a message
<wsdl:message name="FaultError" type="tns:detail"/>

then added fault to the operation
<wsdl:fault name="FaultName" message="tns:FaultError"/>

and then after adding <soap12:fault name="FaultName" use="literal"/>
in the soap 12 section, the editor stopped to complain.

On the server side, I follow the sample to raise the exception with
something like
XmlDocument doc = new XmlDocument();
XmlNode detail = doc.CreateNode(XmlNodeType.Element,
SoapException.DetailElementName.Name,
SoapException.DetailElementName.Namespace);

XmlNode errorType = doc.CreateNode(XmlNodeType.Element,
"ErrorCode", myNS);
errorType.InnerText = "-1";

XmlNode lineNum = doc.CreateNode(XmlNodeType.Element,
"Message", myNS);
lineNum.InnerText = "Error";


detail.AppendChild(errorType);
detail.AppendChild(lineNum);


string errorMsg = "An error was received while processing the
message (see Detail element for more information)";
SoapException exc = new SoapException(errorMsg,
SoapException.ClientFaultCode, "", detail);
throw exc;

Anything I should pay attention on the "Fault Name" in the <wsdl:fault
name="FaultName" message="tns:FaultError"/>?
What is the correspondence between soap exception details and this
FaultName?

Thanks in advance.
 
Reply With Quote
 
Todd
Guest
Posts: n/a
 
      09-10-2008
Was there any examples posted for this? I have the same issue.

Thanks in advance

"(E-Mail Removed)" wrote:

> On Aug 5, 4:01 pm, "John Saunders" <(E-Mail Removed)> wrote:
> > <(E-Mail Removed)> wrote in message
> >
> > news:(E-Mail Removed)...
> >
> > > Hi,

> >
> > > I am planning to use a custom wsdl for my web service, it seems
> > > that the SoapException class provides nice and easy way to handle soap
> > > exception on the server side. Corresponding to the associated fault
> > > definition in the wsdl, how should I define the fault element that
> > > corresponds to the exception SoapException may be raised from server
> > > with message, code, actor and detail?

> >
> > You simply define the structure of the detail section using XML Schema.
> > Then, refer to it in the <wsdl:message> element that defines the fault
> > message. Refer to the fault message in the <wsdl:fault> section using the
> > type attribute.
> >
> > Then, all you have to do is construct an instance of your fault detail and
> > provide it to the SoapException constructor.
> >
> > I don't have time to find or create an example today, but let me know if
> > you're still stuck after this and I'll try to make time.
> >
> > --
> > John Saunders | MVP - Connected System Developer

>
> I have created structure for the detail section
>
> <s:complexType name="detail">
> <s:sequence>
> <s:element name="ErrorCode" type="s:int"/>
> <s:element name="Message" type="s:string"/>
> </s:sequence>
> </s:complexType>
>
> then added a message
> <wsdl:message name="FaultError" type="tns:detail"/>
>
> then added fault to the operation
> <wsdl:fault name="FaultName" message="tns:FaultError"/>
>
> and then after adding <soap12:fault name="FaultName" use="literal"/>
> in the soap 12 section, the editor stopped to complain.
>
> On the server side, I follow the sample to raise the exception with
> something like
> XmlDocument doc = new XmlDocument();
> XmlNode detail = doc.CreateNode(XmlNodeType.Element,
> SoapException.DetailElementName.Name,
> SoapException.DetailElementName.Namespace);
>
> XmlNode errorType = doc.CreateNode(XmlNodeType.Element,
> "ErrorCode", myNS);
> errorType.InnerText = "-1";
>
> XmlNode lineNum = doc.CreateNode(XmlNodeType.Element,
> "Message", myNS);
> lineNum.InnerText = "Error";
>
>
> detail.AppendChild(errorType);
> detail.AppendChild(lineNum);
>
>
> string errorMsg = "An error was received while processing the
> message (see Detail element for more information)";
> SoapException exc = new SoapException(errorMsg,
> SoapException.ClientFaultCode, "", detail);
> throw exc;
>
> Anything I should pay attention on the "Fault Name" in the <wsdl:fault
> name="FaultName" message="tns:FaultError"/>?
> What is the correspondence between soap exception details and this
> FaultName?
>
> Thanks in advance.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SOAP::WSDL, wsdl2perl and soap 1.2 Me Perl Misc 2 04-09-2010 08:00 AM
Does the Java SE 6 beta correspond to a particular Snapshot Release? Mickey Segal Java 1 05-19-2006 06:15 PM
File path does not correspond to URL error for production builds Rob ASP .Net 0 10-14-2004 04:16 PM
soap:fault in WSDL Emanuele Parati ASP .Net Web Services 0 01-14-2004 10:23 AM
is the w3c's schema for wsdl and wsdl/soap binding possibly buggy ? _clb_ Chris Bedford XML 0 08-20-2003 11:52 PM



Advertisments