Click here to Skip to main content
16,007,885 members
Home / Discussions / C#
   

C#

 
GeneralRe: Thousand Seperator in TextBox Pin
freshonlineMax4-Sep-09 20:04
freshonlineMax4-Sep-09 20:04 
QuestionReading The MAC Address Pin
Wamuti4-Sep-09 8:26
Wamuti4-Sep-09 8:26 
AnswerRe: Reading The MAC Address Pin
Xmen Real 4-Sep-09 8:29
professional Xmen Real 4-Sep-09 8:29 
GeneralRe: Reading The MAC Address Pin
Wamuti4-Sep-09 8:52
Wamuti4-Sep-09 8:52 
AnswerRe: Reading The MAC Address Pin
0x3c04-Sep-09 9:02
0x3c04-Sep-09 9:02 
AnswerRe: Reading The MAC Address Pin
Dave Kreskowiak4-Sep-09 10:08
mveDave Kreskowiak4-Sep-09 10:08 
AnswerRe: Reading The MAC Address Pin
Luc Pattyn4-Sep-09 10:25
sitebuilderLuc Pattyn4-Sep-09 10:25 
QuestionCreating a ClientProxy from Scratch Pin
Lochnagar4-Sep-09 8:22
Lochnagar4-Sep-09 8:22 
Hello All,
So, I am usually a .NET developer now working in a ColdFusion shop. I found out recently that the
new .NET WCF format Web Services don't play as nicely as some would have you believe, specifically,
they are quite difficult to access successfully through ColdFusion. . . . The easy answer, create
a .NET Proxy to do the actual web interaction and access the local .NET DLL from ColdFusion (much
easier to integrate). So, that is a little background on the overall project.

Now for the Question:
We are having issues with the Skew Value when trying to send to the web service. We have asked the
other end (our client) to see if they can update on their end, but we want to make sure that we are
updating on our end as well. If this was a .NET only application, I could just add three or four
lines to my app.config or web.config file and this would be an easy fix. But, since working with
ColdFusion, I can't use an app.config or web.config file with my .NET DLL (REALLY wish I could).
So, I am creating the complete proxy from scratch, and I could just use some help looking over my
work, making sure that I am doing it correctly, and making sure that I am actually setting the Skew
Value correctly.

Here is the Method that I create the Client Proxy for calling the web service (basically having to
create in code everything that would normally be in the app.config/web.config):
private static NameSpace.Web_Service.ClientProxy createClientProxy()
{
    // Create MyBinding WSHttpBinding for the Client
    System.ServiceModel.WSHttpBinding myBinding = new System.ServiceModel.WSHttpBinding();
    // Setup MyBinding Basic Values
    myBinding.Name = "SecureBinding";
    myBinding.CloseTimeout = new TimeSpan(0, 1, 0);
    myBinding.OpenTimeout = new TimeSpan(0, 1, 0);
    myBinding.ReceiveTimeout = new TimeSpan(0, 30, 0);
    myBinding.SendTimeout = new TimeSpan(0, 1, 0);
    myBinding.BypassProxyOnLocal = false;
    myBinding.TransactionFlow = false;
    myBinding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
    myBinding.MaxBufferPoolSize = 524288;
    myBinding.MaxReceivedMessageSize = 65536;
    myBinding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text;
    myBinding.TextEncoding = Encoding.UTF8;
    myBinding.UseDefaultWebProxy = true;
    myBinding.AllowCookies = false;

    // Setup MyBinding.ReaderQuotas
    myBinding.ReaderQuotas.MaxDepth = 32;
    myBinding.ReaderQuotas.MaxStringContentLength = 8192;
    myBinding.ReaderQuotas.MaxArrayLength = 16384;
    myBinding.ReaderQuotas.MaxBytesPerRead = 4096;
    myBinding.ReaderQuotas.MaxNameTableCharCount = 16384;

    // Setup MyBinding.ReliableSession
    myBinding.ReliableSession.Ordered = true;
    myBinding.ReliableSession.InactivityTimeout = new TimeSpan(0, 10, 0);
    myBinding.ReliableSession.Enabled = false;

    // Setup MyBinding.Security.Mode
    myBinding.Security.Mode = System.ServiceModel.SecurityMode.TransportWithMessageCredential;

    // Setup MyBinding.Security.Transport
    myBinding.Security.Transport.ClientCredentialType = 
        System.ServiceModel.HttpClientCredentialType.None;
    myBinding.Security.Transport.ProxyCredentialType = 
        System.ServiceModel.HttpProxyCredentialType.None;
    myBinding.Security.Transport.Realm = String.Empty;

    // Setup MyBinding.Security.Message
    myBinding.Security.Message.ClientCredentialType = 
        System.ServiceModel.MessageCredentialType.UserName;
    myBinding.Security.Message.NegotiateServiceCredential = true;
    myBinding.Security.Message.EstablishSecurityContext = true;

    // Create ContractDescription for MyEndpoint
    System.ServiceModel.Description.ContractDescription myContractDesc = 
        new System.ServiceModel.Description.ContractDescription("Web_Service_Name", "Web_Service");

    // Create EndpointAddress for MyEndpoint
    System.ServiceModel.EndpointAddress myepAddress = 
        new System.ServiceModel.EndpointAddress("https://www.webservicelocation.com/WebServiceName/Service.svc");

    // Create MyEndpoint Service Endpoint for the Client
    System.ServiceModel.Description.ServiceEndpoint myEndpoint = 
        new System.ServiceModel.Description.ServiceEndpoint(myContractDesc, myBinding, myepAddress);

    // Create Proxy Service
    NameSpace.Web_Service.Client myProxy = new NameSpace.Web_Service.Client(myBinding, myepAddress);
    BindingElementCollection test = myProxy.ChannelFactory.Endpoint.Binding.CreateBindingElements();
    SymmetricSecurityBindingElement security = new SymmetricSecurityBindingElement();
    security.LocalClientSettings.MaxClockSkew = TimeSpan.FromMinutes(30.00);
    security.LocalServiceSettings.MaxClockSkew = TimeSpan.FromMinutes(30.00);
    SecurityBindingElement bootStrap = new SymmetricSecurityBindingElement();
    bootStrap.LocalClientSettings.MaxClockSkew = TimeSpan.FromMinutes(30.00);
    bootStrap.LocalServiceSettings.MaxClockSkew = TimeSpan.FromMinutes(30.00);
    SecureConversationSecurityTokenParameters secureTokenParams = 
        new SecureConversationSecurityTokenParameters(bootStrap);
    security.ProtectionTokenParameters = secureTokenParams;
    test.Add(security);

    // Add Credentials to Proxy Service
    myProxy.ClientCredentials.UserName.UserName = "MyUserName";
    myProxy.ClientCredentials.UserName.Password = "MyPassword";

    // Return Proxy Service
    return myProxy;
}


And the app.config file that I used to create it is:

<?xml version="1.0"?>
<configuration>
  <configSections>
  </configSections>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="MyBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
            receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" 
            transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
            maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" 
            textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" negotiateServiceCredential="true" 
                algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
        <binding name="SecureBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
            receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" 
            transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" 
            maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
            allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096"
            maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"
                establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://www.WebServiceSite.com/WebService/Service.svc" binding="wsHttpBinding" 
            bindingConfiguration="MyBinding" contract="Web_Service" name="MyEndpoint" />
      <endpoint address="https://www.WebServiceSite.com/WebService/Service.svc" binding="wsHttpBinding" 
            bindingConfiguration="SecureBinding" contract="NameSpace.WebService" name="SecureBinding" />
    </client>
  </system.serviceModel>
  <appSettings>
    <add key="UserName" value="MyUserName" />
    <add key="Password" value="MyPassword" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>
  <startup>
    <supportedRuntime version="v2.0.50727" />
  </startup>
  <system.web>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" 
            type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, 
            System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
            serviceUri="" />
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, 
            System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
            serviceUri="" cacheTimeout="86400" />
      </providers>
    </roleManager>
  </system.web>
</configuration>


If someone could let me know if there are any problems, It works, it runs, and for a while it was fine, but when the two clocks get over 5 minutes apart, it is still having issues. I am trying to figure out if it is just me, or if it is the other end. . . . Any suggestions, any help? Thanks all.

Michael Palmer

"All the world's a chip
And all the men and women merely transistors
They have their inputs and their outputs
And one man, in his time, processes many bytes."
~William Shakespeare~ (coined)
QuestionRegex help Pin
Xmen Real 4-Sep-09 8:12
professional Xmen Real 4-Sep-09 8:12 
AnswerRe: Regex help Pin
PIEBALDconsult4-Sep-09 9:13
mvePIEBALDconsult4-Sep-09 9:13 
GeneralRe: Regex help Pin
Xmen Real 4-Sep-09 13:42
professional Xmen Real 4-Sep-09 13:42 
Questiondetach attach [modified] Pin
sos_amin4-Sep-09 7:04
sos_amin4-Sep-09 7:04 
AnswerRe: detach attach Pin
musefan4-Sep-09 7:16
musefan4-Sep-09 7:16 
AnswerRe: detach attach Pin
Xmen Real 4-Sep-09 8:13
professional Xmen Real 4-Sep-09 8:13 
AnswerRe: detach attach Pin
Pete O'Hanlon4-Sep-09 9:18
mvePete O'Hanlon4-Sep-09 9:18 
QuestionGetting the Values in Combox from database code file Pin
amaankhan4-Sep-09 6:27
amaankhan4-Sep-09 6:27 
AnswerRe: Getting the Values in Combox from database code file Pin
Henry Minute4-Sep-09 8:31
Henry Minute4-Sep-09 8:31 
QuestionWhich is the Best Book for C# programming for Advance Real time Project Pin
amaankhan4-Sep-09 6:04
amaankhan4-Sep-09 6:04 
AnswerRe: Which is the Best Book for C# programming for Advance Real time Project Pin
Not Active4-Sep-09 6:24
mentorNot Active4-Sep-09 6:24 
Questionck facebook user online status? Pin
Jassim Rahma4-Sep-09 5:27
Jassim Rahma4-Sep-09 5:27 
AnswerRe: ck facebook user online status? Pin
stancrm4-Sep-09 6:18
stancrm4-Sep-09 6:18 
Questioncheck Yahoo Messenger user online status? Pin
Jassim Rahma4-Sep-09 5:27
Jassim Rahma4-Sep-09 5:27 
AnswerRe: check Yahoo Messenger user online status? Pin
amaankhan4-Sep-09 6:13
amaankhan4-Sep-09 6:13 
GeneralRe: check Yahoo Messenger user online status? Pin
BabyMouse28-Sep-09 6:11
BabyMouse28-Sep-09 6:11 
GeneralRe: check Yahoo Messenger user online status? Pin
Đỗ Hồng Ngọc20-Oct-09 5:27
professionalĐỗ Hồng Ngọc20-Oct-09 5:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.