Multiple base addresses for WCF Service

If we do not want to explicitly set address for each EndPoint in our service then we define BASE ADDRESS for the EndPoint exposed for our service

clip_image002

And we use it in service configuration as below,

clip_image004

The advantage of having base address is that, if we are changing the service URL, we need to change at only one place instead of going and changing address of each endpoint.

WCF allow us to give multiple base addresses for each type of protocol. And at the run time corresponding endpoint will take the base address.

clip_image006

In above configuration, we added one more base address using net.tcp protocol.

Now at endpoint configuration, we will configure it as below

clip_image008

At the run time WCF automatically will map base address to corresponding endpoint with matched protocol.

For reference full Web.Config will look like


<system.serviceModel>
 <behaviors>
 <serviceBehaviors>
 <behavior name="MyBeh">
 <serviceMetadata httpGetEnabled="true"/>
 <serviceDebug includeExceptionDetailInFaults="false"/>
 </behavior>
 </serviceBehaviors>
 </behaviors>
 <services>
 <service name="WcfService1.Service1"  behaviorConfiguration="MyBeh">
 <endpoint address=""
 binding="basicHttpBinding"
 contract="WcfService1.IService1"/>
 <endpoint address="nete"
 binding ="netTcpBinding"
 contract ="WcfService1.IService1"/>
 <endpoint address="mex"
 binding="mexHttpBinding"
 contract="IMetadataExchange"/>
 <endpoint address="mex1"
 binding="mexTcpBinding"
 contract="IMetadataExchange"/>
 <host>
 <baseAddresses>
 <add baseAddress="<a href="http://localhost:8181/Service1.svc/&quot;/">http://localhost:8181/Service1.svc/"/</a>>
 <add baseAddress="net.tcp://localhost:9876/Service1.svc/"/>
 </baseAddresses>
 </host>
 </service>
 </services>
 </system.serviceModel>

 

Enabling JavaScript IntelliSense on Visual Web Part in SharePoint 2010

Open Visual Studio 2010 and create a Visual Web Part project as selecting from SharePoint 2010 tab

clip_image002

Now provide name of the site where you want to deploy the web part

clip_image003

Click on Validate button to validate the site. If you are able to connect and get below message then we are we are good to go.

clip_image004

Open VisualWebPart1UserControl.ascx and add below script

clip_image006

After adding above script add

clip_image007

Now add below script,

clip_image009

Inside script tag , write a function

clip_image011

And now u can see that in this function IntelliSense is working

clip_image001

So in JavaScript function it would be working like below

clip_image013