2017-05-03 100 views
0

单呼WCF服务我有一个托管的Windows Server的IIS上的WCF服务,并设置为Windows身份验证(在公司内部的用户必须使用域认证登录自己的桌面)。我想用Mono从linux(ubuntu)调用这个WCF服务。我们使用netTcp协议,但它可以改变。我创建服务为:从使用Windows身份验证

var s = new WebTestService.TestServiceClient(); 
s.ClientCredentials.UserName.UserName = "mydomain\\myuser"; 
s.ClientCredentials.UserName.Password = "myPassword"; 

但它仍然不启用通信。

没有人有一个想法在哪里解决这个错误?有没有可能解决?预先感谢。

未处理的异常:System.IO.IOException:无法从 读取数据传输连接:由对等方重置连接。 ---> System.Net.Sockets.SocketException:在 System.Net.Sockets.Socket.Receive(System.Byte []缓冲由对等连接重置,System.Int32 偏移,System.Int32大小,System.Net System.Net.Sockets.NetworkStream.Read(System.Byte [] buffer, System.Int32 offset,System.Int32 size)[0x000b4] :0
---内部异常 堆栈跟踪---在(包装管理到本机) System.Object的结束:__ icall_wrapper_mono_remoting_wrapper(IntPtr的,IntPtr的)
在(包装远程-调用) MonoTest.WebTestService.ITestService :哥提dentity()在 MonoTest.WebTestService.TestServiceClient.GetIdentity()[0x00007]在 < 27f805f676fd42ad978ebb382e24c2d7>:0在MonoTest.Program.Main (System.String []参数)[0x00050]在 < 27f805f676fd42ad978ebb382e24c2d7>:0 [ ERROR]致命未处理 例外信息:System.IO.IOException:无法读取来自 传输连接的数据:将连接复位。 ---> System.Net.Sockets.SocketException:由对端重置的连接数为 System.Net.Sockets.Socket.Receive(System.Byte [] buffer,System.Int32 offset,System.Int32 size,System.Net System.Net.Sockets.NetworkStream.Read(System.Byte [] buffer, System.Int32 offset,System.Int32 size)[0x000b4] :0 ---内部异常 堆栈跟踪---在(包装管理到本机) System.Object的结束:__ icall_wrapper_mono_remoting_wrapper(IntPtr的,IntPtr的)
在(包装远程-调用) MonoTest.WebTestService.ITestService:GetIdentity ()在 MonoTest.WebTes tService.TestServiceClient.GetIdentity()[0x00007]在 < 27f805f676fd42ad978ebb382e24c2d7>:0在MonoTest.Program.Main (System.String []参数)[0x00050]在 < 27f805f676fd42ad978ebb382e24c2d7>:0

+0

我想这里还有其他问题。你能否在没有身份验证的情况下工作,然后在身份验证工作后添加身份验证? – Popo

+1

使用匿名身份验证,它就像一个魅力。 –

回答

1

我使用对于Windows身份验证在我的WCF web服务一个用户名和密码,我给你的用户名和密码,就像这样:

s.ClientCredentials.Windows.ClientCredential.UserName = "mydomain\\myuser"; 
//in my case I don't use a domain though. 
s.ClientCredentials.Windows.ClientCredential.Password = "myPassword"; 
//I acutally use .SecurePassword and assign it SecureString 
+0

我想知道s.ClientCredentials.Windows.ClientCredential.UserName和s.ClientCredentials.UserName.UserName之间有什么区别...(并且尽量不去思考为什么如此有趣以命名一个属性,如s.ClientCredentials.UserName.Password ...) –

+0

@ZoltanHernyak'ClientCredentials.Windows.ClientCredential'类型为'NetworkCredential','ClientCredentials.UserName'类型为'UserNamePasswordClientCredential'我同意非常容易混淆的名字。希望我的回答有用。 – Popo

0

我能够让它在Mono运行。

即使使用“匿名”身份验证,netTcpBinding也不起作用(根据我的经验)。

wsHttpBinding不起作用(方法或操作未实现)。

只有basicHttpBinding的作品。它与TransportCredentialOnlyTransport安全模式,与clientCredentialType Windows传输设置。在这种情况下,客户端可以以“域\用户名”格式和密码设置用户名。