0

Since this question tells me that SoapHttpClientProtocol is not thread safe. And, my real life testing tells me this is true, as my SoapHeader properties keep getting mixed up between calls. Is there a way to make sure that I can use this across threads and keep my properties correct? And make sure I don't run into the example given in that question of one thread thinking the connection is open, when another thread has closed it? Do I need to worry about the soap header values after my request has been made? How can I verify the properties are as I set them until the request has been issued?

Community
  • 1
  • 1
Alex
  • 12,749
  • 3
  • 31
  • 45
  • Why not assign to each thread a separate instance of SoapHttpClientProtocol? – Vitaliy Liptchinsky Dec 22 '09 at 15:27
  • I have tried that, and it still seems as though multiple requests change the properties on the server side. And even though in the local instance I set the propeties right, when the request gets made it may end up being acted on under properties of a different call. – Alex Dec 22 '09 at 15:31
  • So, the server isn't handling it properly then? – Hans Passant Dec 22 '09 at 16:22
  • @nobugz, it is possible that it's the server. These are 3rd party services we call. I assumed I was doing it wrong. Is there a way I could track it to the server? That way if it is on their side I could possibly get a fix. – Alex Dec 22 '09 at 17:21

1 Answers1

1

The first thing I would ask is does your service work correctly if you do not make it multi-threaded. If you make subsequent calls do they all work correctly and give you the desired results? If not then there is a problem on the server side more than likely.

To see what you are sending you could serialize down the soap message before it goes. Make sure it's getting generated correctly.

My job blocks access to a lot of websites but CodeProject has some examples if I remember correctly.

If the single thread works have the serialization layer in place and have it write the files to disk in your multi-threaded scenario. Then you can see what is working and what is not by what your code thinks it's sending.

More than likely your calls are getting mixed by the server since you are trying to establish multiple connections while it may be seeing your endpoint as one value, kind of like being behind a NAT firewall. Which means you may be getting a connection but one of your other threads gets its message through first. If that is the case you could try spinning each thread up in it's own app domain and see if it does anything for you. Not saying that it will work, but not sure off the top of my head what else may be available for you to try.

Joshua Cauble
  • 1,349
  • 8
  • 7
  • Yes, single threaded works just fine. That's the code running right now, I was trying to speed up the work. The other two suggestions I will try both writing the calls out and trying the app domain. Thanks. – Alex Dec 23 '09 at 17:28
  • Another thought for testing to see if it's you or them. Create a simple exe (console based is fine) that just keeps hitting the service. Create two versions, say for two different request types. Check your response against what you know you should get and run both exes at the same time. It should loop and keep resending so as to create volume and hopefully repeat your problem. Have it fail out if it gets a bad response. May help to eliminate some avenues. Also, if it works then maybe the app domain thing might as well or there is something in your code causing the corruption. – Joshua Cauble Dec 23 '09 at 18:05
  • thanks for the help on figuring it out. It is definetly on the server side now that I can actually see my soap messages and examine them. Didnt get my problem fixed, but now I know to figure otu a work around rather than a fix. – Alex Jan 07 '10 at 13:09
  • Glad I could help. Too bad it's on there side it's always hard to get third parties to update stuff. – Joshua Cauble Jan 07 '10 at 20:24