Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / April 2008

Tip: Looking for answers? Try searching our database.

Removing Timestamp from a SOAP message with WSE 3.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sònia - 14 Mar 2008 12:43 GMT
Hi,
I'm developping an WSE client application that calls a webservice with
WS-Security.
I'm sending a SOAP message like

************
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://www.meteocatserveis.com/axis/services/ConsultaEstacions"
xmlns:types="http://www.meteocatserveis.com/axis/services/ConsultaEstacions/encodedTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
       <soap:Header>
         <wsa:Action>
         </wsa:Action>
         
<wsa:MessageID>urn:uuid:65f4b395-f208-4286-9656-6239f096e26c</wsa:MessageID>
         <wsa:ReplyTo>
           
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
         </wsa:ReplyTo>
         
<wsa:To>http://www.meteocatserveis.com/axis/services/ConsultaEstacions</wsa:To>
         <wsse:Security>
           <wsu:Timestamp
wsu:Id="Timestamp-36736541-67a9-44fb-9779-9a422bc94c50">
             <wsu:Created>2008-03-13T16:07:12Z</wsu:Created>
             <wsu:Expires>2008-03-13T16:12:12Z</wsu:Expires>
           </wsu:Timestamp>
           <wsse:UsernameToken
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-364b2ace-9b69-41cf-be74-a814910008fe">
             <wsse:Username>tvc</wsse:Username>
             <wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1
.0#PasswordDigest">cTPEB2dduqv9xOiuhOAAoKVfVtI=</wsse:Password
>
             <wsse:Nonce>cWkO9B6G3wY/AND1BRSUAg==</wsse:Nonce>
             <wsu:Created>2008-03-13T16:07:12Z</wsu:Created>
           </wsse:UsernameToken>
         </wsse:Security>
       </soap:Header>
       <soap:Body
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <q1:dades_ultimes xmlns:q1="http://consultaEstacions" />
       </soap:Body>
     </soap:Envelope>

*****************************************

But the webservice receiving that message don't undersand the "Timestamp" tag.
How can I remove it?
ed - 15 Apr 2008 17:45 GMT
I had this exact problem using a vb.net client accessing a Java web service.
The solution takes 3 steps:

1.) Create custom ClientOutputFilter
2.) Create a custom Assertion that uses filter from step 1
3.) Bind service to custom Assertion

Step 1
Custom Filter(Called by Custom Assertion)
Class ClientOutputFilter
 Inherits SendSecurityFilter
 Private parentAssertion As UsernameClientAssertion
 Private filterContext As FilterCreationContext

 Public Sub New(ByVal parentAssertion As UsernameClientAssertion, ByVal
filterContext As FilterCreationContext)
   MyBase.New(parentAssertion.ServiceActor, False,
parentAssertion.ClientActor)
   Me.parentAssertion = parentAssertion
   Me.filterContext = filterContext
 End Sub
 Public Overrides Function ProcessMessage(ByVal envelope As
Microsoft.Web.Services3.SoapEnvelope) As
Microsoft.Web.Services3.SoapFilterResult
   Dim securityElement As XmlElement = envelope.CreateElement("wsse",
"Security", "http://schemas.xmlsoap.org/ws/2002/07/secext")
   Dim mustUnderstandAttribute As XmlAttribute =
envelope.CreateAttribute(envelope.DocumentElement.Prefix, "mustUnderstand",
envelope.DocumentElement.NamespaceURI)
   Dim userToken As New UsernameToken(parentAssertion.username,
parentAssertion.password, PasswordOption.SendPlainText)

   mustUnderstandAttribute.Value = "true"
   securityElement.AppendChild(userToken.GetXml(envelope))
   envelope.CreateHeader.AppendChild(securityElement)
   Return SoapFilterResult.Continue
 End Function
End Class

Step 2 Custom Assertion
Public Class UsernameClientAssertion
 Inherits SecurityPolicyAssertion
 Public username As String
 Public password As String

 Public Sub New(ByVal username As String, ByVal password As String)
   Me.username = username
   Me.password = password
 End Sub

 Public Overloads Overrides Function CreateClientOutputFilter(ByVal context
As FilterCreationContext) As SoapFilter
   Return New ClientOutputFilter(Me, context)
 End Function

 Public Overrides Function CreateClientInputFilter(ByVal context As
FilterCreationContext) As SoapFilter
   ' we don't provide ClientInputFilter
   Return Nothing
 End Function

 Public Overrides Function CreateServiceInputFilter(ByVal context As
FilterCreationContext) As SoapFilter
   ' we don't provide any processing for web service side
   Return Nothing
 End Function

 Public Overrides Function CreateServiceOutputFilter(ByVal context As
FilterCreationContext) As SoapFilter
   ' we don't provide any processing for web service side
   Return Nothing
 End Function
End Class

Step 3: Bind proxy to custom assertion

Private WS As New Service.ServicenameWSE
Private token As UsernameToken = New UsernameToken(USERNAME, PASSWORD,
PasswordOption.SendPlainText)
ProvideUsernameToken.Assertions.Add(New UsernameClientAssertion(USERNAME,
PASSWORD))
WS.SetClientCredential(token)
WS.SetPolicy(ProvideUsernameToken)

Good luck, if anyone has a better way to do this I'm all ears

- Ed

> Hi,
> I'm developping an WSE client application that calls a webservice with
[quoted text clipped - 48 lines]
> But the webservice receiving that message don't undersand the "Timestamp" tag.
> How can I remove it?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.