Wednesday, September 28, 2011

Migration to SharePoint 2010: Part 1 - SOAP Service Connection

At work we began the path of changing from a PHP and Java shop into a .NET shop.  Specifically migrating over to use SharePoint 2010 for both internal and external facing websites.  A large undertaking for a company that has traditionally avoided .NET.  In other words, an IT staff that doesn't know the framework at all (including myself!).

Before going any further I should warn you, the reader of this blog post, that at the time of writing this I was the only developer that my company had.  Therefore,  I really had no other team member that I could bounce questions off of in my pursuit to conquer .NET and SharePoint.

I took the initiative to learn as much as I could as quickly as I could.  Training and books on topics such as ASP.NET, C#, SharePoint 2010, Visual Studio 2010, and so on.  All of that training preparing me for the moment where I would be handed that first official .NET related development project.  That time had come...

I was assigned a task to connect SharePoint 2010 to a set of WSDL files using SOAP on another server where our billing software resides.  Essentially with two goals from management with a primary objective of confirming this would even work:
  1. Allow a customer to authenticate their account via form submission on a page within SharePoint's publishing portal (public website).  The Web Service should take the username and password, returning a valid or invalid authentication attempt.
  2. Expose data through Web Services into SharePoint lists on our internal (intranet) facing SharePoint site.
Whether right or wrong I performed the steps listed below.

The first step I took was to try connecting to these services by using SharePoint's native "SOAP Service Connection" tool under SharePoint Designer's "Data Sources" object.
  1. Open Microsoft SharePoint Designer 2010.
  2. Click on Open Site.
  3. Under Site name enter the location to the SharePoint site you wish to connect too.  Click Open.
  4. Under the quick launch area (located to the left of the screen) expand the Site Objects tab.
  5. Click on Data Sources.  The summary area should now show you a list of data sources that are inside SharePoint.  Such as lists, document libraries, etc.
  6. Click on SOAP Service Connection in the ribbon, located at the top of the screen.  You will see the following:

  7. The Service description location is where you will want to put the path to your WSDL.
    1. A good sample Web Service is
  8. Click on Connect Now or Reconnect.  You should see your other fields light up.
The rest is pretty self-explanatory.  You can edit your parameters by clicking Modify at the bottom of the screen.  Or you can flag them to be set during runtime.  Under the General tab you can place a name and description to your SOAP service.  I didn't experiment with the Login tab, but it sounds simple enough.

To test the Web Service and make sure all is well I had to get creative.  Keeping in mind I am new to SharePoint Designer and the such.
  1. Still remaining in SharePoint Designer, click on the Site Pages option under Site Objects.
  2. Add a new ASPX page.  Call it something like WSTest.aspx or whatever is easy to distinguish it from the rest of your SharePoint site.  You can add this page by:
    1. Click on the drop-down menu for Page from your ribbon at the top of the screen.
    2. Select ASPX and rename the file.
  3. Right-click on the newly created file from your summary screen.
  4. Select Edit File in Advanced Mode from the context menu.
  5. You will see some code but, what you are interested in is the code between the <form> tags.  Click and place your cursor between those tags.
  6. From your ribbon you will want to select the Insert tab.
  7. Under the Data Views & Forms category you will want to select Data View.  This will present you with a list of options.
  8. Scroll down until you find the SOAP service you created under Data Sources earlier.  If everything is successful, you should see a new DataFormWebPart that contains data fed back from the Web Service you just called.  If you get an error you may need to check your logs to determine why.

This attempt to connect to the third-party WSDL files was a huge flop though despite my best efforts.

The first issue lie in the WSDL files themselves.  The vendor for our billing software was using a RPC style rather than a Document style on their generated WSDL files.  Which isn't supported by the type of service connection we were trying to create.

We worked with the vendor and they upgraded their format to a document format which could be consumed by SharePoint.  Now we are getting somewhere!

Alas, the victory was short lived.  It appeared that the operation names within the WSDL did not match the input names.
<wsdl:message name="sampleMessageName">
    <wsdl:part element="impl:sampleMessageName" name="parameters">


<wsdl:operation name="sampleOperationName">
When SharePoint was looking for "sampleMessageName" to be "sampleOperationName".  The above is a very crude example.  This caused the request packets to be incompatible with what the vendor was looking for.

The vendor gave up trying to resolve this and informed us that their Web Services just won't work with SharePoint the way we were attempting too.  If we wanted it to work we would have to customize each WSDL their tool was generating.  And we would have to do it ourselves after they delivered the WSDL files to us.  They wouldn't do it for us.  In short, we were on our own.

Okay, so back to the drawing board it is.  We wouldn't be able to add a simple "SOAP Service Connection" inside SharePoint Designer.

I decided that I would now attempt to create a "ASP.NET Web Service" project inside Visual Studio 2010 and use that as a bridge between SharePoint 2010 and the incompatible WSDL files.  I would hit my own web services that would in turn send the correctly formatted packet to our vendor's web services.

The details of that project will be included in Part 2 of this Migration to SharePoint 2010 series.  More to come, wish me luck...

No comments:

Post a Comment