WCF 拒绝将客户端凭据附加到请求
我有一个正在尝试与之交互的网络服务,但是无论我尝试什么,它都拒绝随请求一起发送客户端凭据。
我的 app.config 中的安全块看起来像
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
然后我像这样使用服务代理:
Dim MyUploadEvent As New EventUploadWSv1.EventUploadWSv1PortTypeClient("IEventUploadWSv1Port")
Dim request As New EventUploadWSv1.webservice_source_event_FileUploadRequest
' First Thing I tried
MyUploadEvent.ClientCredentials.UserName.UserName = "..."
MyUploadEvent.ClientCredentials.UserName.Password = "..."
' Also Tried this based on a question here and a couple of blogs
'Dim defaultCredentials As ClientCredentials
'Dim loginCredentials As New ClientCredentials()
'loginCredentials.UserName.UserName = "..."
'loginCredentials.UserName.Password = "..."
'defaultCredentials = MyUploadEvent.Endpoint.Behaviors.Find(Of ClientCredentials)()
'MyUploadEvent.Endpoint.Behaviors.Remove(defaultCredentials)
'MyUploadEvent.Endpoint.Behaviors.Insert(0, loginCredentials)
' Configure Request Object
' This throws an exception
MyUploadEvent.fileUpload(request)
我还尝试使用其他所有 ClientCredentials 字段(MyUploadEvent.ClientCredentials 和 MyUploadEvent.ClientFactory.ClientCredentials),但服务器不断返回一条消息,告诉我没有 SOAP附有认证信息。我检查了通过网络发送的消息,没有任何地方提到用户名或密码。我显然在这里遗漏了一些我不应该遗漏的东西。
I have a web service I'm trying to interface with however no matter what I try it is refusing to send the clients credentials along with the request.
The security block in my app.config looks like
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
Then I use the service proxy like this:
Dim MyUploadEvent As New EventUploadWSv1.EventUploadWSv1PortTypeClient("IEventUploadWSv1Port")
Dim request As New EventUploadWSv1.webservice_source_event_FileUploadRequest
' First Thing I tried
MyUploadEvent.ClientCredentials.UserName.UserName = "..."
MyUploadEvent.ClientCredentials.UserName.Password = "..."
' Also Tried this based on a question here and a couple of blogs
'Dim defaultCredentials As ClientCredentials
'Dim loginCredentials As New ClientCredentials()
'loginCredentials.UserName.UserName = "..."
'loginCredentials.UserName.Password = "..."
'defaultCredentials = MyUploadEvent.Endpoint.Behaviors.Find(Of ClientCredentials)()
'MyUploadEvent.Endpoint.Behaviors.Remove(defaultCredentials)
'MyUploadEvent.Endpoint.Behaviors.Insert(0, loginCredentials)
' Configure Request Object
' This throws an exception
MyUploadEvent.fileUpload(request)
I have also tried using every other ClientCredentials field (MyUploadEvent.ClientCredentials and MyUploadEvent.ClientFactory.ClientCredentials) but the server keeps returning a message telling me no SOAP authentication information is attached. I've checked the message being sent over the wire and there is no mention of the username or password anywhere. I am clearly missing something here that I shouldn't be.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用
TransportWithMessageCredential
安全模式。 Transport 仅使用Transport
元素中定义的配置,而Message
元素被完全忽略。You must use
TransportWithMessageCredential
security mode. Transport simply uses only configurations defined inTransport
element andMessage
element is completely ignored..