Question : dynamic httpbinding for web services

hi can i ask how to do a dynamic httpbinding for web services
how to pass a webservices string  to the app.conf file?
thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="S4_Services_OutlookIntegrationBinding" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm=""><!--<extendedProtectionPolicy policyEnforcement="NEVER" />--></transport>
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://abc.com/abc.service.php"
                binding="basicHttpBinding" bindingConfiguration="S4_Services_OutlookIntegrationBinding"
                contract="S4_Service.S4_Services_OutlookIntegrationPort" name="S4_Services_OutlookIntegrationPort" />
        </client>
    </system.serviceModel>
</configuration>

Answer : dynamic httpbinding for web services

HI!

Server Endpoints :


<endpoint address ="http://localhost:8080/Greetings/ws" binding="wsHttpBinding" contract="Greetings.IGreeting"/>
<endpoint address ="http://localhost:8081/Greetings/basicI" binding="basicHttpBinding" contract="Greetings.IGreeting"/>
<endpoint address ="http://localhost:8091/Greetings/basicII" binding="basicHttpBinding" contract="Greetings.IGreeting"/>

Client EndPoints :


<endpoint address="http://localhost:8080/Greetings/ws" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IGreeting" contract="ServiceReference1.IGreeting"
name="WSHttpBinding_IGreeting">
<identity>
<userPrincipalName value="Navneet-PC\Navneet" />
</identity>
</endpoint>
<endpoint address="http://localhost:8081/Greetings/basicI" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IGreeting" contract="ServiceReference1.IGreeting"
name="BasicHttpBinding_IGreeting" />
<endpoint address="http://localhost:8091/Greetings/basicII" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IGreeting" contract="ServiceReference1.IGreeting"
name="BasicHttpBinding_IGreeting1" />

Client Program Main :


ServiceReference1.GreetingClient client = new ServiceReference1.GreetingClient(new BasicHttpBinding()
, new System.ServiceModel.EndpointAddress("http://localhost:8081/Greetings/basicII"));
Console.WriteLine(client.GoodEvening("Navneet"));
Console.ReadLine();

ServiceReference1.GreetingClient client = new ServiceReference1.GreetingClient(new BasicHttpBinding()
, new System.ServiceModel.EndpointAddress("http://localhost:8091/Greetings/basicII"));
Console.WriteLine(client.GoodEvening("Navneet"));
Console.ReadLine();

Here if you see for your clarity I have basicHttpBinding withdiffrent endpoint
basicI, basicII

similarly if you want to switch between wsHttpBinding and basicHttpBinding you also have to change the binding  along with the address.

However you can also switch between the EnpPoint like

ServiceReference1.GreetingClient client = new ServiceReference1.GreetingClient("BasicHttpBinding_IGreeting1");

OR

ServiceReference1.GreetingClient client = new ServiceReference1.GreetingClient("
BasicHttpBinding_IGreeting");

Hope this helps!

Random Solutions  
 
programming4us programming4us