Wednesday, March 19, 2008

Displaying External Web Services Data in SharePoint Server 2007

Prerequisites

  • SharePoint Server 2007 (MOSS 2007) Enterprise Edition
  • SharePoint Server 2007 SDK v1.3 or newer

Building the Application Definition File

  1. If you haven't already installed the BDC Definition Editor, install it. It should be located here: "%ProgramFiles%\2007 Office System Developer Resources\Tools\BDC Definition Editor". Just launch the setup.exe program to install it.
  2. From the Programs menu, startup the Microsoft ® Business Data Catalog Definition Editor.
  3. Click on "Add LOB SYstem".
  4. Click on "Connect to Webservice".
  5. Enter the following Web Service URL in the Url field: http://ws.cisa.ca/WehireWS/JobsWs.asmx?WSDL.
  6. Click on Connect.
  7. Click on the "Add Web Method" side-button.
  8. Drag the GetJobsByTitle method onto the Design area.
  9. Call the LOB System Name "JobsWesternCanadaWebService" (without quotes).
  10. In the Metadata Objecta pane, click on the JobsWesternCanadaWebService system.
  11. In the Properties pane, set the WildcardCharacter field to "$" (without quotes).
  12. Ensure that that WsdlAuthenticationMode is set to PassThrough.
  13. Set the DefaultDisplayName to "Jobs in Western Canada Web Service" (without quotes).
  14. In the Metadata Objects pane, expand the Entities node, then click on Entity0.
  15. In the Properties pane, set the Title to "Jobs in Western Canada" (without quotes).
  16. Set the Name property to "JobsWesternCanada" (without quotes).
  17. Set the DefaultDisplayName to "Jobs in Western Canada" (without quotes).
  18. In the Metadata Objects pane, right-click on the Identifiers node, then click on Add Identifier.
  19. In the Properties pane, set the Name to "Title" (without quotes).
  20. In the Metadata Objects pane, locate the GetJobsByTitle method, then locate the title parameter.
  21. Expand the title parameter's nodes until you reach the Item node, then select it.
  22. In the Properties pane, set the Identifier property to Title[JobsWesternCanada].
  23. Set the name property to "Title" (without quotes).
  24. In the Metadata Objects pane, expand the Return parameter's nodes until you reach the Item node, then click on the Title node.
  25. In the Properties pane, set the Identifier property to Title[JobsWesternCanada].
  26. In the Metadata Objects pane, locate the Filters node of the GetJobsByTitle method.
  27. Right-click on the Filters node, then click on Add Filter.
  28. In the Properties pane, set the Name to "TitleEqualsFilter" (without quotes).
  29. Set the DefaultDisplayName to "Title" (without quotes).
  30. Set the FilterType to Equals.
  31. In the Metadata Objects pane, locate and expand the last title parameter node of the GetJobsByTitle method, then select it.
  32. In the Properties pane, set the FilterDescriptor to TitleEqualsFilter.
  33. In the Metadata Objects pane, right-click on the Instances node of the GetJobsByTitle method, then click on Add Method Instance.
  34. Select Association as the Method Instance Type.
  35. In the Source Entities pane, set the entity to JobsWesternCanada.
  36. Click on OK.
  37. In the Properties pane, set the Name property to "GetJobsByTitleAssociationInstance" (without quotes).
  38. In the Metadata Objects pane, right-click on the Instances node of the GetJobsByTitle method, then click on Add Method Instance.
  39. Select Finder as the Method Instance Type.
  40. Click on OK.
  41. In the Properties pane, set the Name to "GetJobsByTitleFinderInstance" (without quotes).
  42. Test to ensure the Finder method works by a) right-clicking on the GetJobsByTitleFinderInstance method, b) clicking on Execute, c) entering ".NET Web Developer" (without quotes) in the Value field, d) then clicking on the Execute button. You should get results back from the web service. Close the test form.
  43. In the Metadata Objects pane, select the JobsWesternCanadaWebService LOB system.
  44. Click on the Export button, then save the file as "JobsWesternCanadaWebService.xml" (without quotes).

Importing the BDC Definition File

  1. Open up the SharePoint 3.0 Central Administration web page.
  2. Under Shared Services Administration, click on the shared service listed.
  3. Under Business Data Catalog, click on "Import application definition".
  4. Click on the Browse button, then locate and open the JobsWesternCanadaWebService.xml file.
  5. Click on Import.
  6. You should've gotten a success message. Click on OK.
  7. Click on Manage Permissions.
  8. Add the users/groups you'd like to grant permission to execute the LOB system.

Displaying the Web Service Data via a Business Data List

  1. In the SharePoint Server 2007 site, navigate to a web part page where you'd like to see the web service in action.
  2. Click on Site Actions, then Edit Page.
  3. Click on "Add a Web Part".
  4. Expand the "All Web Parts" node.
  5. Under Business Data, check the "Business Data List" web part.
  6. Click on Add.
  7. Click on Edit in the "Business Data List" web part, then click on "Modify shared web part".
  8. Click on the Browse icon, next to the Type field.
  9. Select JobsWesternCanadaWebService_Instance, then click on OK.
  10. Click on the Apply button.
  11. Click on the OK button.
  12. Click on the Publish button, if necessary, to save the page changes.
  13. In the "Jobs in Western Canada List" web part, enter ".NET Web Developer" (without quotes) in the "Title is equal to" field.
  14. Click on Retrieve Data. As of March 23, 2008, there is one result listed.

1 comment:

Timmy! said...

Thanks for the nice write up! This got me 95% of the way of where I needed to go!