Thursday, February 28, 2013

Create a dataview in sharepoint with datasource webservice

To create DataView in SharePoint Desgner based on SOAP Web Service do the following Steps:
  1. From Navigation Pane, click Data Sources.  From Ribbon, click the SOAP Service Connection Menu Item. DataSource Dialog Properties will appear:
    1. Service Description Location: This is the URL to the service description (WSDL) file.
      ex: http://[SharePoint Site URL]/_vti_bin/lists.asmx?wsdl
      Click Connect Now so SharePoint Designer can retrieve the description file. 
    2. Data Command: Like a REST service connection, this box identifies the command  that your data source is going to be configured to run. You need to support multiple datasource if you will use multiple command.
    3. Port: If the web service supports multiple interfaces, they will be listed here. The
      default port will be selected.
    4. Operation: When the Connect Now button is clicked, the wizard retrieves the WSDL
      file, which defines all of the operations that can be performed on the web service.
    5. Parameters: As mentioned previously, if the operation selected in the previous step
      requires parameters, those will be listed.
      If you tried to modify any parameter to set its value you will find check-box you must checked it if you want to your parameter dynamic read from (Control, QueryString, Cookie, Post Data,...)
  2. The wizard has two other tabs that are the same as the other data sources. 
    1. The Login tab can be used to set default login credentials.
    2. The General tab is used to provide a description of the data source configuration. 
  3. Create a new web part page, call it TestSOAP.aspx, and open it in Edit mode. . 
  4. Click in the web part zone, and then from the Ribbon, click Data View and add your data source.
  5. Drag your needed columns from the datasource and apply your adjustment and formatting of data view.
  6. When you finish you can export DataView by the following steps:
    1. click into the Web Part ribbon tab under List View Tools
    2. You have two options, To Site Gallery, and To File. 
Tips and Tricks:
  1. If you set parameter in your web service to read from connected webpart you find ParameterBindings appeared as below (check text in red). You can add more parameters with same way:

  2. <DataSources>
       <SharePoint:SoapDataSource runat="server" id="SoapDataSource1" AuthType="Basic"  
      WsdlPath="http://ServerUrl/_vti_bin/lists.asmx?WSDL"
      SelectUrl="http:// ServerUrl/_vti_bin/lists.asmx"
      SelectAction="http://schemas.microsoft.com/ sharepoint/soap/GetList"
      SelectPort="ListsSoap"
      SelectServiceName="Lists"
      AuthUserName="yellowdc\spadmin"
      AuthPassword="P@ssw0rd"><
      SelectCommand>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
       <GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <listName>{listName}</listName>
      </GetList>

    </soap:Body></soap:Envelope>
      </SelectCommand>
        <SelectParameters><WebPartPages:DataFormParameter Name="listName"    
              ParameterKey="listName" PropertyName="ParameterValues"        
              DefaultValue="{43AFBEAA-674C-406B-9ACB-0870CD4B88F2}"/>
        </SelectParameters>
      </SharePoint:SoapDataSource>
    </DataSources>


    <parameterbindings>
      <ParameterBinding Name="listName" Location="None"  
                                        DefaultValue="{43AFBEAA-674C-406B-9ACB-0870CD4B88F2}"/>
      <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
      <ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
      <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
      <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
      <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
      <ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
    </parameterbindings>

1 comment:

Unknown said...

Step 4 - click in the part zone. Not sure what that is. All I see is 'Add a web part' and when I click in it a popup prompts for what to add.