用户名令牌; WCF-> Java Web服务问题 [英] Username token; WCF->Java web service issues
问题描述
嗨
Hi 我正在与Java Web服务进行WCF互操作,该Java Web服务需要一个用户名令牌(此处没有ssl和证书). I am doing WCF interoperability with a java web service which expects a Username token (no ssl and certificates here). java Web服务期望这样的请求: The java web service expects a request like this: < soap:Envelope xmlns:soap =" http://www.w3.org/2003/05/soap-envelope"> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> < soap:Header>< wsse:Security xmlns:wsse ="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0. xsd" mustUnderstand ="1"> <soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1"> < wsse:UsernameToken> <wsse:UsernameToken> < wsse:Username> oc4jadmin</wsse:Username> <wsse:Username>oc4jadmin</wsse:Username> < wsse:Password Type =" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"欢迎< /wsse:密码> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">welcome</wsse:Password> </wsse:UsernameToken> </wsse:UsernameToken> </wsse:Security> </wsse:Security> </soap:Header> </soap:Header> < soap:Body xmlns:ns1 ="http://usernametoken/"> <soap:Body xmlns:ns1="http://usernametoken/"> < ns1:GetSalaryElement> <ns1:GetSalaryElement> < ns1:name xmlns:ns2 ="http://www.w3.org/2001/XMLSchema-instance" ns2:nil ="true"/> <ns1:name xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance" ns2:nil="true"/> </ns1:GetSalaryElement> </ns1:GetSalaryElement> </soap:Body> </soap:Body> </soap:Envelope> </soap:Envelope> 我在WCF客户端中的绑定设置: My bindings setting in the WCF client: <绑定> <bindings> < wsHttpBinding> <wsHttpBinding> <绑定名称=" SalaryWSSoapHttp"> <binding name="SalaryWSSoapHttp"> <安全模式=消息"> <security mode="Message"> <消息clientCredentialType ="UserName"/> <message clientCredentialType="UserName"/> </security> </security> </binding> </binding> </wsHttpBinding> </wsHttpBinding> </bindings> </bindings> 我正在这样设置ChannelFactory的用户名和密码: and I am setting the username and password on the ChannelFactory like this: 使用(SalaryWSProxy代理=新的SalaryWSProxy()) using (SalaryWSProxy proxy = new SalaryWSProxy()) { proxy.ChannelFactory.Credentials.UserName.UserName ="oc4jadmin"; proxy.ChannelFactory.Credentials.UserName.UserName = "oc4jadmin"; proxy.ChannelFactory.Credentials.UserName.Password ="welcome"; proxy.ChannelFactory.Credentials.UserName.Password = "welcome"; Console.WriteLine(proxy.GetSalary(比尔·盖茨")); Console.WriteLine(proxy.GetSalary("Bill Gates")); } 现在,当调用GetSalary方法时,来自WCF客户端的请求是此?: Now when invoking the GetSalary method, the request from the WCF client is this ?: < s:信封xmlns:a ="http://www.w3.org/2005/08/addressing"; xmlns:s ="http://www.w3.org/2003/05/soap-envelope"> <s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"> < s:Header>< a:Action s:mustUnderstand ="1"> http://usernametoken//GetSalary</a:Action> <s:Header><a:Action s:mustUnderstand="1">http://usernametoken//GetSalary</a:Action> < a:MessageID> urn:uuid:231866d0-566e-4fab-aa55-c9e5550e072e</a:MessageID> a:ReplyTo< a:地址> http://www.w3.org/2005/08/addressing/anonymous</a:Address> <a:MessageID>urn:uuid:231866d0-566e-4fab-aa55-c9e5550e072e</a:MessageID><a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> </a:ReplyTo> </s:Header> </s:Header> < s:Body> <s:Body> < GetSalaryElement xmlns:i =" http://www.w3.org/2001/XMLSchema-instance" xmlns =" http://usernametoken/"> <GetSalaryElement xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://usernametoken/"> < name>比尔·盖茨</name> <name>Bill Gates</name> </GetSalaryElement> </GetSalaryElement> </s:Body> </s:Body> </s:信封> </s:Envelope> 如您所见,现在其中包含安全标头了? As you can see there is now security header in it ??? 当然,期望值是: 故障:{缺少< wsse:Security>在SOAP标头中"} Fault: {"Missing <wsse:Security> in SOAP Header"} 我在这里做错了什么?我本来希望看到< wsse:Security>在这里的标题中...... What am I doing wrong here ?, I would have expected to see <wsse:Security> in the header here.... 在xpsp2上运行Beta 2. running beta 2 on xpsp2. 感谢@llan 让我猜;您必须使用安全的运输工具(ssl)或证书. WCF希望这样做,否则它并不是真正的安全. let me guess; you have to use a secure transport(ssl) or a certificate....; WCF expects this, otherwise it's not really secure. 如果是这种情况,那就很好了,这里抛出一个异常.如果使用basicHttpbinding,就会得到这个. if this is the case it would have been nice with an exception thrown here. You get this if you use the basicHttpbinding. /艾伦(Allan) 这篇关于用户名令牌; WCF-> Java Web服务问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!推荐答案