Web services WCF头痛-使用用户名和密码通过HTTP进行身份验证
全部, 我正在尝试打一个.NETWCF电话,我认为这应该很简单,但事实证明非常困难。我真的需要一些帮助,我是一个WCF新手。以下是场景: 我试图从C调用PeopleSoft CI web服务,该服务在PeopleSoft端使用用户名和密码进行保护。 核心问题是,用户名和密码等安全标头没有正确发送到PeopleSoft web服务。 在过去的几天里,我做了很多研究,做了很多尝试,并取得了一些进展,但归根结底,我无法让这项工作发挥作用。 下面列出的项目是我最初的出发点,我不会用我尝试过的所有选项来模糊线程。 原始WSDL指向一个标准HTTP站点。我也尝试过使用HTTPS,我认为这可以解决问题。不走运 web服务架构如下所示:Web services WCF头痛-使用用户名和密码通过HTTP进行身份验证,web-services,wcf,passwords,peoplesoft,Web Services,Wcf,Passwords,Peoplesoft,全部, 我正在尝试打一个.NETWCF电话,我认为这应该很简单,但事实证明非常困难。我真的需要一些帮助,我是一个WCF新手。以下是场景: 我试图从C调用PeopleSoft CI web服务,该服务在PeopleSoft端使用用户名和密码进行保护。 核心问题是,用户名和密码等安全标头没有正确发送到PeopleSoft web服务。 在过去的几天里,我做了很多研究,做了很多尝试,并取得了一些进展,但归根结底,我无法让这项工作发挥作用。 下面列出的项目是我最初的出发点,我不会用我尝试过的所有选项来模
<HEADER>
<USERID>myID</USERID>
<PASSWORD>????</PASSWORD>
<LANGUAGE_CD>ENG</LANGUAGE_CD>
</HEADER>
<that>Ithid</that>
<Strcurrent_action>target</Strcurrent_action>
<Strnew_action>action</Strnew_action>
<StractionConfirm>action</StrpasswordConfirm>
</MyAction__This__Stuff_SELF>
我从svcutil生成了C类和配置文件。app.config的显示方式如下:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyStuff_Binding" />
</basicHttpBinding>
</bindings>
我使用以下代码拨打电话:
MyStuff_PortTypeClient=new MyStuff_PortTypeClientMyStuff_Port;
client.ClientCredentials.UserName.UserName=MyLogon;
client.ClientCredentials.UserName.Password=MyPassword;
MyAction\uuuuuuuuuuuuuuuuuuuuuuuu CompIntfc\uuuuuuuuuuuuu用户\uuprofiletypeshape actionShape=新的MyAction\uuuuuuuuuuuuuuuuuuuuuuuuuuuuu;
UserIDTypeShape targetUser=新的UserIDTypeShape;
尝试
{client.MyStuff\u myActionShape;//调用}
正如我所提到的,我已经尝试了很多方法,包括在basicHttpBinding中更改安全性、消息和传输选项,在wsHttpBinding、自定义头文件等方面进行了尝试,但毫无乐趣
对于如何通过http或https通过用户名和密码安全地调用PeopleSoft web服务,我非常感谢您的帮助和成功的示例
谢谢我也遇到了很多麻烦,但还是成功了。。。某种程度上。我不得不手动将标题放入配置文件中,就像这样
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PeopleSoft_Binding">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="MyEndpoint"
bindingConfiguration="PeopleSoft_Binding"
contract="ProxyClass.ProxyClass_PortType"
binding="basicHttpBinding"
address="https://MyPeoplesoftInstance/PeopleSoftServiceListeningConnector">
<headers>
<wsse:Security soap:mustUnderstand="1"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>TheUser</wsse:Username>
<wsse:Password>ThePassword</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
</endpoint>
</client>
</system.serviceModel>
</configuration>
虽然这是可行的,但并不理想,因为凭据存储在配置文件中。理想情况下,我希望能够以编程方式传递凭据,并且我已经尝试了大量涉及XmlSerializer、WCF配置等的内容,但到目前为止没有任何效果。希望这个答案能帮助人们进入下一步
using (var client = new MyProxy.MyProxy_PortTypeClient("MyEndpoint"))
{
client.MyMethod();
}