Consuming non-asmx SOAP 1.1 Web Service in C# with Header Security

半城伤御伤魂 提交于 2019-12-25 17:49:18

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/7606380/consuming-non-asmx-soap-1-1-web-service-in-c-sharp-with-header-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!