Groups | Blog | Home
all groups > dotnet web services enhancements > january 2005 >

dotnet web services enhancements : CryptographicException: WSE502


John O'Neill
1/20/2005 4:59:16 PM
Hi

I have been using the UsernameSigningCode console sample supplied with WSE
2.0 SP2 and managed to get it working with ease. Based on the code from
console sample, I created a similar windows forms client and got that
working easily too. My problem is when I call web methods asynchronously,
ie, instead of calling serviceProxy.StockQuoteRequest(symbols) I call
serviceProxy.BeginStockQuoteRequest(symbols, new
AsyncCallback(StockQuoteCallback), null); and in my callback method I
display the results in a multiline text box on the form. Mostly, everthing
is fine and works as expected, but every now and then I get the following
error :

System.Security.Cryptography.CryptographicException: WSE502: The target
element referenced by the following id can not be found in the message:
Id-8fe25618-0141-4b4a-b767-bdc26ea70a30. Make sure that the element is
present at the time when the signing or encryption operation is performed.
at System.Web.Services.Protocols.WebClientAsyncResult.WaitForResponse()
at System.Web.Services.Protocols.WebClientProtocol.EndSend(IAsyncResult
asyncResult, Object& internalAsyncState, Stream& responseStream)
at
System.Web.Services.Protocols.SoapHttpClientProtocol.EndInvoke(IAsyncResult
asyncResult)
at
UsernameSignCodeFormsClient.StockServiceWse.EndStockQuoteRequest(IAsyncResult
asyncResult) in C:\Program Files\Microsoft
WSE\v2.0\Samples\CS\QuickStart\UsernameSigning\Code\UsernameSignCodeFormsClient\UsernameSigningProxy.cs:line
63
at UsernameSignCodeFormsClient.Form1.StockQuoteCallback(IAsyncResult
result) in c:\program files\microsoft
wse\v2.0\samples\cs\quickstart\usernamesigning\code\usernamesigncodeformsclient\form1.cs:line
140

Like I say, normally everything runs ok and I just get the error every now
and then. I wanted to investigate further, so I made a modification to my
test form so that it makes a series of 10 calls to to the
BeginStockQuoteRequest in a loop with a 1 second delay between each call and
now I get the error more or less everytime but at random points within the
loop, ie the error might occur on the 5th callback, or 7th callback etc.

I hope someone can help as I don't even know where to begin to look to sort
it out!

Thanks

John

Sidd
1/25/2005 11:15:25 PM
Hi John,

Do you see this problem if you invoke this sample using the non-async
way as well? i.e. serviceProxy.StockQuoteRequest instead of the
serviceProxy.BeginStockQuoteRequest. Did you modify this quickstart in any
other possible way? The reason I ask is that if not, then I am probably
going to investigate this in more detail on my end.

Thanks,

Sidd [MSFT]

[quoted text, click to view]
UsernameSignCodeFormsClient.StockServiceWse.EndStockQuoteRequest(IAsyncResul
t
[quoted text, click to view]
WSE\v2.0\Samples\CS\QuickStart\UsernameSigning\Code\UsernameSignCodeFormsCli
ent\UsernameSigningProxy.cs:line
[quoted text, click to view]
wse\v2.0\samples\cs\quickstart\usernamesigning\code\usernamesigncodeformscli
ent\form1.cs:line
[quoted text, click to view]

John O'Neill
1/26/2005 4:55:39 PM
Hi Sidd

I can confirm that I do not see this problem when making synchronous calls
with serviceProxy.StockQuoteRequest. It only happens when making
asynchronous calls with serviceProxy.BeginStockQuoteRequest. The main client
code remains unchanged as I copied it directly from UsernameSigningClient.cs
and dropped it into a windows form class and wrote a bit of code to update
the GUI etc.

The only slight modification I have made is to put a
System.Threading.Thread.Sleep(1000) at the end of the StockQuoteRequest web
method in UsernameSigningService.asmx.cs before the results are returned
just to make the web method take a little longer to simulate a real-world
operation. If I take the sleep out, I still get the same error appearing,
but it doesn't seem to occur as frequently.

If you have trouble recreating my problem I will be happy to post a zip of
my project for you to try.

Thanks for your help.

John

[quoted text, click to view]

AddThis Social Bookmark Button