I want if client send wrong credentials then service throw soap exception but I tried but still no luck.
see my updated code from here https://github.com/karlosRivera/EncryptDecryptASMX
Anyone can download my code and run in their PC to capture the problem.
see this area
[AuthExtension]
[SoapHeader("CredentialsAuth", Required = true)]
[WebMethod]
public string Add(int x, int y)
{
string strValue = "";
if (CredentialsAuth.UserName == "Test" && CredentialsAuth.Password == "Test")
{
strValue = (x + y).ToString();
}
else
{
throw new SoapException("Unauthorized", SoapException.ClientFaultCode);
}
return strValue;
}
For this line throw new SoapException("Unauthorized", SoapException.ClientFaultCode);
The response XML body is not getting change which I have seen from my soapextension process message function.
So I have two issues now
1) I want throw SoapException
from service for which soap response need to be changed.
2) From client side I need to catch the SoapException
Please view my latest code from the link and tell me what to change. thanks
Another option is to avoid sending
SoapException
s, but more complex objects that embed error semantics. E.g.In this case your method could look like this:
Result
can be developed to include an array of field/input errors to return more precise error messages related to incorrect input parameter values.