问题描述
1、首先PFX已经生成了,.NET调用时相关数据已经加入2、但是报这个错误:org.apache.ws.security.WSSecurityException:Anerrorwasdiscoveredprocessingthe<wsse:Security>header了
解决方案
解决方案二:
该回复于2012-07-16 10:26:31被版主删除
解决方案三:
需要自己加Header.objectIClientMessageInspector.BeforeSendRequest(refSystem.ServiceModel.Channels.Messagerequest,System.ServiceModel.IClientChannelchannel){UsernameTokenut=newUsernameToken("USERNAME","PASSWORD",PasswordOption.SendHashed);XmlElementsecurityElement=ut.GetXml(newXmlDocument());MessageHeadermyHeader=MessageHeader.CreateHeader("Security","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",securityElement,false);request.Headers.Add(myHeader);returnConvert.DBNull;}
具体内容参考下面的讨论:ErrorinWCFclientconsumingAxis2webservicewithWS-SecurityUsernameTokenPasswordDigestauthenticationscheme
解决方案四:
我是用数字证书的,不是用用户名和密码的。
解决方案五:
数字证书也成功加载了。
解决方案六:
以下是.net生成的配置文件:<?xmlversion="1.0"encoding="utf-8"?><policyDocumentxmlns="http://schemas.microsoft.com/wse/2003/06/Policy"><mappingsxmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy"><!--Thefollowingpolicydescribesthepolicyrequirementsforallserviceswhodonothaveamappinginthisfile.--><defaultEndpoint><defaultOperation><requestpolicy="#Sign-X.509"/><responsepolicy="#Encrypt-X.509"/><faultpolicy=""/></defaultOperation></defaultEndpoint></mappings><policiesxmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"xmlns:wssp="http://schemas.xmlsoap.org/ws/2002/12/secext"xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy"xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"><wsp:Policywsu:Id="Sign-X.509"><!--MessagePredicateisusedtorequireheaders.ThisassertionshouldbeusedalongwiththeIntegrityassertionwhenthepresenceofthesignedelementisrequired.NOTE:thisassertiondoesnotdoanythingforenforcement(send-side)policy.--><wsp:MessagePredicatewsp:Usage="wsp:Required"Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body()wsp:Header(wsa:To)wsp:Header(wsa:Action)wsp:Header(wsa:MessageID)wse:Timestamp()</wsp:MessagePredicate><!--TheIntegrityassertionisusedtoensurethatthemessageissignedwithX.509.ManyWebserviceswillalsousethetokenforauthorization,suchasbyusingthe<wse:Role>claimorspecificX.509claims.--><wssp:Integritywsp:Usage="wsp:Required"><wssp:TokenInfo><!--TheSecurityTokenelementwithintheTokenInfoelementdescribeswhichtokentypemustbeusedforSigning.--><wssp:SecurityToken><wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3</wssp:TokenType><wssp:TokenIssuer>CN=tzyyyyghclient</wssp:TokenIssuer><wssp:Claims><!--ByspecifyingtheSubjectNameclaim,thepolicysystemcanlookforacertificatewiththissubjectnameinthecertificatestoreindicatedintheapplication'sconfiguration,suchasLocalMachineorCurrentUser.TheWSEX.509CertificateToolisusefulforfindingthecorrectvaluesforthisfield.--><wssp:SubjectNameMatchType="wssp:Exact">CN=tzyyyyghclient</wssp:SubjectName><wssp:X509ExtensionOID="2.5.29.14"MatchType="wssp:Exact">K+EfdvTR8l0bnajaGZpR7tu4a7U=</wssp:X509Extension></wssp:Claims></wssp:SecurityToken></wssp:TokenInfo><wssp:MessagePartsDialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body()wsp:Header(wsa:Action)wsp:Header(wsa:FaultTo)wsp:Header(wsa:From)wsp:Header(wsa:MessageID)wsp:Header(wsa:RelatesTo)wsp:Header(wsa:ReplyTo)wsp:Header(wsa:To)wse:Timestamp()</wssp:MessageParts></wssp:Integrity></wsp:Policy><wsp:Policywsu:Id="Encrypt-X.509"><!--TheConfidentialityassertionisusedtoensurethattheSOAPBodyisencrypted.--><wssp:Confidentialitywsp:Usage="wsp:Required"><wssp:KeyInfo><!--TheSecurityTokenelementwithintheKeyInfoelementdescribeswhichtokentypemustbeusedforEncryption.--><wssp:SecurityToken><wssp:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3</wssp:TokenType><wssp:TokenIssuer>CN=tzyyyyghclient</wssp:TokenIssuer><wssp:Claims><!--ByspecifyingtheSubjectNameclaim,thepolicysystemcanlookforacertificatewiththissubjectnameinthecertificatestoreindicatedintheapplication'sconfiguration,suchasLocalMachineorCurrentUser.TheWSEX.509CertificateToolisusefulforfindingthecorrectvaluesforthisfield.--><wssp:SubjectNameMatchType="wssp:Exact">CN=tzyyyyghclient</wssp:SubjectName><wssp:X509ExtensionOID="2.5.29.14"MatchType="wssp:Exact">K+EfdvTR8l0bnajaGZpR7tu4a7U=</wssp:X509Extension></wssp:Claims></wssp:SecurityToken></wssp:KeyInfo><wssp:MessagePartsDialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body()</wssp:MessageParts></wssp:Confidentiality></wsp:Policy></policies></policyDocument>
解决方案七:
大侠你解决了吗我也遇到了同样的问题谢谢