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:
- 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.
- Expose data through Web Services into SharePoint lists on our internal (intranet) facing SharePoint site.
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.
- Open Microsoft SharePoint Designer 2010.
- Click on Open Site.
- Under Site name enter the location to the SharePoint site you wish to connect too. Click Open.
- Under the quick launch area (located to the left of the screen) expand the Site Objects tab.
- 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.
- Click on SOAP Service Connection in the ribbon, located at the top of the screen. You will see the following:
- The Service description location is where you will want to put the path to your WSDL.
- A good sample Web Service is http://www.w3schools.com/webservices/tempconvert.asmx?WSDL.
- Click on Connect Now or Reconnect. You should see your other fields light up.
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.
- Still remaining in SharePoint Designer, click on the Site Pages option under Site Objects.
- 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:
- Click on the drop-down menu for Page from your ribbon at the top of the screen.
- Select ASPX and rename the file.
- Right-click on the newly created file from your summary screen.
- Select Edit File in Advanced Mode from the context menu.
- 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.
- From your ribbon you will want to select the Insert tab.
- Under the Data Views & Forms category you will want to select Data View. This will present you with a list of options.
- 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">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.
<wsdl:part element="impl:sampleMessageName" name="parameters">
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...