2017-08-10 3 views
0

Web参照としてプロジェクトにJava WSDLを追加しました。私はエンドポイント上のサービスを呼び出すためにそれを消費しています。 ASMXファイルにWebMethodを追加し、そこにサービスを呼び出しました。要件は、WSEセキュリティを使用し、X509証明書で要求に署名することです。WSSEセキュリティヘッダーからタイムスタンプを削除するC#ASMX/WCFサービス

残念ながら、タイムスタンプで問題が発生していますが、「ヘッダーの処理中にエラーが検出されました」というメッセージが表示されています。私はそれからTimeStamp要素を削除する場合、同じ要求はSoapUIから動作します。ここで This is how the request look like

問題が解決しないWCF

を使用してセキュリティ要素

//Set WSSE Security 
    svc.RequestSoapContext.Security.Timestamp.TtlInSeconds = 300; 
    svc.RequestSoapContext.Security.MustUnderstand = true; 
    svc.RequestSoapContext.Security.Tokens.Add(newtoken); 
    Microsoft.Web.Services3.Security.MessageSignature signature = new Microsoft.Web.Services3.Security.MessageSignature(newtoken); 
    signature.SignatureOptions = Microsoft.Web.Services3.Security.SignatureOptions.IncludeSoapBody;    
    svc.RequestSoapContext.Security.Elements.Add(signature); 

===============

を作成するコードですたとえ私がWCFを使っていても。 IncludeTimestamp = falseを追加するとすぐに、リクエストは送信されず、trueに設定するとリクエストを作成できます。ここで

はWCFコードです -

 //Create Endpoint 
     EndpointAddress address = new EndpointAddress((istest == true ? CHORUS_UFB_EMMA : CHORUS_UFB_PROD)); 

     //Add Certificate to EndPoint Service 
     X509Certificate2 cert = new X509Certificate2(@"Certificate Path", "Password", X509KeyStorageFlags.PersistKeySet); 

     //Setup custom binding with HTTPS + Body Signing + Soap1.1 
     CustomBinding binding = new CustomBinding(); 

     //HTTPS Transport 
     HttpsTransportBindingElement transport = new HttpsTransportBindingElement(); 

     //Set Security Binding as Transport 
     TransportSecurityBindingElement tsec = SecurityBindingElement.CreateCertificateOverTransportBindingElement(MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConvers‌​ation13WSSecurityPol‌​icy12BasicSecurityPr‌​ofile10); 
     tsec.EnableUnsecuredResponse = true; 
     tsec.AllowInsecureTransport = true; 
     tsec.SecurityHeaderLayout = SecurityHeaderLayout.Lax; 
     tsec.LocalServiceSettings.DetectReplays = false; 
     tsec.LocalClientSettings.DetectReplays = false; 
     tsec.IncludeTimestamp = false; 
     tsec.SetKeyDerivation(false); 
     tsec.EndpointSupportingTokenParameters.Signed.Add(new SecureConversationSecurityTokenParameters()); 

     //Setup for SOAP 11 and UTF8 Encoding 
     TextMessageEncodingBindingElement textMessageEncoding = new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8); 

     //Bind in order (Security layer, message layer, transport layer) 
     binding.Elements.Add(tsec); 
     binding.Elements.Add(textMessageEncoding); 
     binding.Elements.Add(transport); 

Here is the generated request using above code この上の任意の助けをいただければ幸いです。

答えて

0

これは、クライアントと呼び出し元のサービスがホストされているWebサーバーとの間の時間の差異によって発生する可能性があります。

両方のサーバーの時刻が一致し、同期しているかどうかを再度確認します。時間は5分以内にする必要があります。

関連する問題