WCF 拒绝将客户端凭据附加到请求

发布于 2024-12-14 18:54:49 字数 1437 浏览 1 评论 0原文

我有一个正在尝试与之交互的网络服务,但是无论我尝试什么,它都拒绝随请求一起发送客户端凭据。

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖上得阳光 2024-12-21 18:54:50

您必须使用 TransportWithMessageCredential 安全模式。 Transport 仅使用 Transport 元素中定义的配置,而 Message 元素被完全忽略。

You must use TransportWithMessageCredential security mode. Transport simply uses only configurations defined in Transport element and Message element is completely ignored..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文