Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am accessing a WCF service in my solution from URL provided(Third party).
The service is secured with WS Http Binding, having an user name ,password authentication with soap request.

I have added a service reference in my solution and passed a user name and password to service object.
C#
ServiceReferenceAdmin client = new ServiceReferenceAdmin("WSHttpBinding_IAdmin");
            client.ClientCredentials.UserName.UserName = "one";
            client.ClientCredentials.UserName.Password = "two";
            client.callServMethod("test");


When I am calling service method, connection is created with service method-->Used a fiddler to get request and response --> and came to know --
In soap request timestap is going as a local system timestamp which is in GMT format.
And server time zone(where service i hosted) is Pacific time zone (UTC -08:00).
Because of this the authentication is failing and rejecting service method call.

Tried following different ways :
1) Changed system time zone to Pacific time zone (UTC -8:00)
2)
C#
using(new OperationContextScope(client.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(new SecurityHeader("UsernameToken", "one", "two"));
                
                string str = "acp";
            }


C#
public class SecurityHeader : MessageHeader
        {
            
            private readonly UsernameToken _usernameToken;

            public SecurityHeader(string id, string username, string password)
            {
                _usernameToken = new UsernameToken(id, username, password);
            }

            public override string Name
            {
                get { return "Security"; }
            }

            public override string Namespace
            {
                get { return "namespace"; }
            }

            protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(UsernameToken));
                serializer.Serialize(writer, _usernameToken);
            }
        }


After all this settings SOAP request is not changing from GMT to Pacific timezone.

How to make change in timestamp of soap request?
Is there any way I can set time Zone in IIS ?

Thank you in advance for your response.
Please let me know your feedback and suggestions
Posted
Updated 22-Mar-17 2:19am

1 solution

- Change System time zone to required time zone
- restart system to affect changes
- it will reset timezone to new
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900