我正在呼叫Java Web服务,并带有必填符号。我可以拨打电话,Web服务会响应。我也向SoapUI发出请求。 问题在于该消息具有一个BinarySecurityToken,因为它引发异常,所以我无法阅读。
异常:传入消息已使用令牌进行签名,该令牌为 用不同的东西来加密身体。没想到
谢谢
如果我用Fiddler的响应转换二进制安全令牌,就可以了。
如何在异常发生前获取二进制安全令牌? 我尝试使用“端点行为”,但是在我无法阅读之前会抛出错误。
CustomBinding binding = new CustomBinding();
//HTTPS Transport
HttpsTransportBindingElement transport = new HttpsTransportBindingElement();
//Body signing
AsymmetricSecurityBindingElement asec = (AsymmetricSecurityBindingElement)SecurityBindingElement.CreateMutualCertificateBindingElement(MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);
asec.SetKeyDerivation(false);
asec.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
asec.IncludeTimestamp = false;
asec.EnableUnsecuredResponse = true;
asec.RequireSignatureConfirmation = false;
asec.AllowSerializedSigningTokenOnReply = true;
asec.LocalClientSettings.DetectReplays = true;
//Bind in order (Security layer, message layer, transport layer)
binding.Elements.Add(asec);
binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8));
binding.Elements.Add(transport);
sr1.WS_eFacturaSoapPortClient ws = new sr1.WS_eFacturaSoapPortClient();
ws.Endpoint.Binding = binding;
ws.Endpoint.Contract.ProtectionLevel =
System.Net.Security.ProtectionLevel.Sign;
ws.ClientCredentials.ClientCertificate.Certificate = cert;
ws.ClientCredentials.ServiceCertificate.DefaultCertificate = certU;
ws.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;