0

First time poster so please take it a bit easy on me if I break any posting rules - I have read them and I think I'm right.

I've been searching for a while before posting and can't seem to find a guide on what I am trying to do so I thought I would post here.

I need to write a C# .NET 3.5 program to consume a web service developed in Java. I have practice consuming ASMX web services in .NET using Web References from my experience writing Dynamics CRM plugins and software but this has me stumped.

My first attempt was to use a Web Reference (yes, I know - not WCF) however the web service requires a PasswordDigest (SHA-1 with nonce and created), a username token and timestamp token in the SOAP header and I couldn't find a way to add these to the SOAP header using the Web Reference.

My second attempt was to use a Service Reference (I believe, but I am probably wrong haha, that this is WCF) however I don't have much practice with this and any tutorials I found online were not much help.

Each time when I try to use the WS, I get a rejection from the server for being unable to authenticate.

My question is how do I consume a Web Service with these requirements in C# .NET 3.5?

Thanks.

jacobappleton
  • 538
  • 8
  • 22
  • To create the proxy, open “Add service reference” dialog and put the service URL there, adding `?wsdl` at the end. – Artem Koshelev Sep 30 '11 at 06:13
  • After creating proxy with "Add Web Reference" dialog or wsdl.exe, you can override GetWebRequest and GetWebResponse methods, to play with headers sent to server. – L.B Sep 30 '11 at 06:41

1 Answers1

2

IIRC, Microsoft WSE (either 2.0 or 3.0) had something called UsernameToken, which you need to stuff somewhere in the outgoing SOAP message and you're all set. Granted, this answer leaves a lot to be desired, so I'll throw a couple links at you and hope you'll wade through:

http://www.codeproject.com/KB/webservices/WS-Security.aspx

http://www.reliablesoftware.com/articles/WSESecurity.html

http://www.devx.com/security/Article/15634

(And this all shows yet again how flawed SOAP and WSDL actually are).

Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
  • 1
    So I ended up dropping my .NET version back to 2.0, installing WSE 3.0 and following the instructions in your third link to get this to work. Thank you very much! As a measure of curiosity, is this whole problem caused by Microsoft or the SOAP/WSDL protocol, and why? It seems odd that I couldn't handle this with normal .NET libraries and instead had to revert to obsolete libraries... – jacobappleton Oct 03 '11 at 04:58
  • AFAIK, WSDL just doesn't contain enough information on how exactly to secure a web service. Never in my experience I had a more or less real-world web service (read: created.by some dork who thought That if WS-* standards exist, they must all be used in many a strange ways) that would just work when added a reference to – Anton Gogolev Oct 03 '11 at 05:22
  • Haha yeah there seems to be too many of those dorks who use these things just because they can. Thank you again for your help! – jacobappleton Oct 03 '11 at 06:05
  • @AntonGogolev I ask a similar question, would you please check it, here: http://stackoverflow.com/questions/13266468/add-header-to-the-simple-web-service-request – Saeid Nov 07 '12 at 10:51