Simulating Exception scenarios for third party services  
Author Message
AshishMalhotra





PostPosted: Connected Services Framework, Simulating Exception scenarios for third party services Top

Hi,

I am trying to simulate a scenario where I have a third party webservice as a participant in my Session manifest. This service throws an exception (a normal .NET exception) based on some condition. Since this is a third party service, I do not have access to code and will not be able to ensure that exception thrown is of should be of type SoapFaultException.

The following is the code for the web service method that throws exception:

[WebMethod]

public string HelloWorld() {

throw new Exception("Testing exceptions");

return "Hello World";

}

I get the following in Session_OutputTrace.webinfo:

<processingStep description="Processed message">
<soap:Envelope xmlns:wsa="
http://www.hide-link.com/ " xmlns:wsse=" http://www.hide-link.com/ " xmlns:wsu=" http://www.hide-link.com/ " xmlns:soap=" http://www.hide-link.com/ ">
<soap:Header>
<wsa:Action> http://www.hide-link.com/ ;/wsa:Action>
<wsa:FaultTo>
<wsa:Address>http://blrkec21592d/Session30/Session.ashx</wsa:Address>
<wsa:ReferenceProperties>
<csfse:SessionID xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">urn:7963033c-e1cb-4d51-88e2-1b0cbc0aee54</csfse:SessionID>
<csfse:OriginalFaultTo xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">http://localhost/HelloWorldService/Service.asmx</csfse:OriginalFaultTo>
<csfse:OriginalMessageID xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">urn:uuid:9fb0b071-72b4-46a0-9611-866dc2794766</csfse:OriginalMessageID>
</wsa:ReferenceProperties>
</wsa:FaultTo>
<wsa:From>
<wsa:Address>http://blrkec21592d/Session30/Session.ashx</wsa:Address>
<wsa:ReferenceProperties>
<csfse:SessionID xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">urn:7963033c-e1cb-4d51-88e2-1b0cbc0aee54</csfse:SessionID>
<csfse:OriginalFrom xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">http://localhost/HelloWorldService/Service.asmx</csfse:OriginalFrom>
<csfse:OriginalMessageID xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">urn:uuid:9fb0b071-72b4-46a0-9611-866dc2794766</csfse:OriginalMessageID>
</wsa:ReferenceProperties>
</wsa:From>
<wsa:MessageID>urn:uuid:f1821c46-99a8-4905-8db9-2777ff257364</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:7152e3e2-3386-4f2b-a140-52461fc5f2f2</wsa:RelatesTo>
<wsa:ReplyTo>
<wsa:Address>http://blrkec21592d/Session30/Session.ashx</wsa:Address>
<wsa:ReferenceProperties>
<csfse:SessionID xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">urn:7963033c-e1cb-4d51-88e2-1b0cbc0aee54</csfse:SessionID>
<csfse:OriginalReplyTo xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">http://localhost/HelloWorldService/Service.asmx</csfse:OriginalReplyTo>
<csfse:OriginalMessageID xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">urn:uuid:9fb0b071-72b4-46a0-9611-866dc2794766</csfse:OriginalMessageID>
</wsa:ReferenceProperties>
</wsa:ReplyTo>
<wsa:To>soap.tcp://blrkec21592d:2006/InitiatorService</wsa:To>
<csfse:SessionID xmlns:csfse="
http://Microsoft/ConnectedServices/2006/06/Session/">urn:7963033c-e1cb-4d51-88e2-1b0cbc0aee54</csfse:SessionID>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-1f1e147f-5ea6-41e6-82c3-720f415d508b">
<wsu:Created>2006-09-05T07:15:40Z</wsu:Created>
<wsu:Expires>2006-09-05T07:20:40Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.Exception: Testing exceptions
at Service.HelloWorld() in e:\Work\CSF\CSF3.0\CSF3.0 Dev lite\Samples3.0DevLite\HelloWorldService\App_Code\Service.cs:line 18
--- End of inner exception stack trace ---</faultstring>
<faultactor>http://blrkec21592d/</faultactor>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
</processingStep>

Now I have to some how ensure that Session routes this exception (a soap fault message) to a proper handler. I tried adding following routes to session Manifest:

<Route>

<Criteria>(ACTION EQ *)</Criteria>

<Destination>InitiatorService[AnyResp]</Destination>

</Route>

<Criteria>(ACTION EQ '*')</Criteria>

<Destination>InitiatorService[AnyResp]</Destination>

</Route>

<Route>

<Criteria>(ACTION EQ ' http://www.hide-link.com/ ')</Criteria>

<Destination>InitiatorService[ http://www.hide-link.com/ ]</Destination>

</Route>

and added following methods to my recepient participant:

[Operation(Action = "AnyResp", Oneway = true)]

public void AnyResp(Object o)

{

System.Diagnostics.Debug.WriteLine("Any Response called.");

}

[Operation(Action = " http://www.hide-link.com/ ;, Oneway = true)]

public void UnknownResp(Object o)

{

System.Diagnostics.Debug.WriteLine("Any Response called.");

}

But I was not able to get exception message in any of the handlers. Can anyone guide me

Thanks,

Ashish



Connected Services Framework1  
 
 
SenthilN-msft





PostPosted: Connected Services Framework, Simulating Exception scenarios for third party services Top

I answered a similar question some time ago.

If you look at the Session Routing rules specified at the bottom of the page in the following URL, you will get a good understanding on how to handle the routing in general.

http://msdn2.microsoft.com/en-us/library/aa303326.aspx

In any case, try the following, this should work for you.

<Route>

<Criteria> MESSAGE EQ 'Fault' AND MESSAGENS EQ 'http://www.w3.org/2003/05/soap-envelope' OR MESSAGE EQ 'Fault' AND MESSAGENS EQ 'http://schemas.xmlsoap.org/soap/envelope' </Criteria>

<Destination>InitiatorService[ErrorHandleAction]</Destination>

</Route>

Thanks