Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   Define Correspond Fault for the Soap Exception in the WSDL (http://www.velocityreviews.com/forums/t787644-define-correspond-fault-for-the-soap-exception-in-the-wsdl.html)

huohaodian@gmail.com 08-05-2008 03:43 PM

Define Correspond Fault for the Soap Exception in the WSDL
 
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.

John Saunders 08-05-2008 08:01 PM

Re: Define Correspond Fault for the Soap Exception in the WSDL
 
<huohaodian@gmail.com> wrote in message
news:34e4c03c-3903-449d-9b2f-678f1bdf8b23@m45g2000hsb.googlegroups.com...
> 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


huohaodian@gmail.com 08-06-2008 03:39 PM

Re: Define Correspond Fault for the Soap Exception in the WSDL
 
On Aug 5, 4:01*pm, "John Saunders" <n...@dont.do.that.com> wrote:
> <huohaod...@gmail.com> wrote in message
>
> news:34e4c03c-3903-449d-9b2f-678f1bdf8b23@m45g2000hsb.googlegroups.com...
>
> > 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.

huohaodian@gmail.com 08-07-2008 03:24 PM

Re: Define Correspond Fault for the Soap Exception in the WSDL
 
On Aug 5, 4:01*pm, "John Saunders" <n...@dont.do.that.com> wrote:
> <huohaod...@gmail.com> wrote in message
>
> news:34e4c03c-3903-449d-9b2f-678f1bdf8b23@m45g2000hsb.googlegroups.com...
>
> > 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.

Todd 09-10-2008 08:31 PM

Re: Define Correspond Fault for the Soap Exception in the WSDL
 
Was there any examples posted for this? I have the same issue.

Thanks in advance

"huohaodian@gmail.com" wrote:

> On Aug 5, 4:01 pm, "John Saunders" <n...@dont.do.that.com> wrote:
> > <huohaod...@gmail.com> wrote in message
> >
> > news:34e4c03c-3903-449d-9b2f-678f1bdf8b23@m45g2000hsb.googlegroups.com...
> >
> > > 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.
>



All times are GMT. The time now is 05:31 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.