SharePoint Gen

The official blog of Chandrasekar, Microsoft SharePoint PFE

Using User control (Web service call ) in SharePoint Web part

Using User control (Web service call ) in SharePoint Web part

  • Comments 6
Everyone knows how easy it is to use an user control( web service call) in normal ASP.NET application and map it with ObjectDataSource control.  But in SharePoint, when ObjectDataSource  control is used, it will throw the error "The type specified in the TypeNameProperty can be found".  The reason being that the proxy class required to connect with the web service is not available in SharePoint. 

 

This is what we need to do, to make create proxy and make it work

 

Ø  Using WSDL.exe ( found under ..\Program Files\Microsoft SDKs\Windows\v6.0A\bin ) run the command wsdl /out:myProxyClass.cs   “http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL”

 

Ø  Create dll using the proxy cs file.  This can be done using CSC.exe ( found under ..\Windows\Microsoft.NET\Framework\vx ) and running the command

csc /out:CodeBehindCompiled.dll /target:library CodeBehind_compiled.cs

Note that there is a space between “csc”, “/out…”, “/target…” and “CodeBehind….”.

 

Ø  Now deploy the dll in the bin folder of the SharePoint web application bin directory ( found under ..\inetpub\wwwroot\wss\virtualdirectories\..\bin)

 

Ø  Add the SafeControl entry for both the web part and the proxy dll in the web.config file.

 

Ø  Have the code for referring the class name of the proxy class for ObjectDataSource. 

 

Ø  In the web.config file, give Full trust level

<trust level=”Full” originUrl=””/>

 

That’s it.  Now add the web part in the SharePoint page and you should see the web service data in it !

Leave a Comment
  • Please add 4 and 6 and type the answer here:
  • Post