Server Did Not Recognise The Value Of HTTP Header SOAPAction (Or How Not To Add A New WebMethod to an existing WebService)

This can come about when your Web Services References file (automatically generated by Visual Studio) is out of sync with your asmx file because you have manually hacked added some Web Methods. Make sure that all your WebMethods have corresponding entries in the Web Service Web Reference file (Reference.vb or Reference.cs).

WARNING: If you are trying to Add a new WebMethod to an existing Web Service do not do what I did below. It will only consign you to a Journey of Pain.

I am maintaining an app. that has a large WebService that operates on a group of DataSets. Each DataSet has three WebMethods associated with it. I created a new DataSet, cut and pasted the three standard Web Methods the app. needs to operate on the new DataSet and manually hacked the Reference.vb file to set up the calls to Invoke the Web Method and the Async versions of the Web Method i.e this stuff:

Public Function GetPreviewSEODataSetByDomain(ByVal domaincode As Integer) As System.Data.DataSet
Dim results() As Object = Me.Invoke(“GetPreviewSEODataSetByDomain”, New Object() {domaincode})
Return CType(results(0), System.Data.DataSet)
End Function

BUT I only manually hacked in the necessary Invokes for ONE of the WebMethods, not all three. For some reason this caused the SOAPAction error. When I removed the other two WebMethods from the asmx file the error went away.

If the above does not pertain to you, make sure you haven’t messed up the Web Service Namespace.

Now here’s what I should have done:

How To Add A New WebMethod to an existing WebService

1. Add the new Web Method to your asmx file. Decorate with WebMethod attribute of course.
2. Get Visual Studio to update the WebReference file, Reference.vb/Reeference.cs. This file does not belong to the Web Service per se. Rather it belongs to the Project which calls the WebService. Visual Studio generates it when you add the Web Reference.

To update it, locate the reference to your Web Service in your calling Project’s Web Reference folder, right-click and select Update Web Reference from the Context Menu. No more hacking, everything works, pain in cranium stops. To celebrate, I recommend making yourself a free instant coffee from the staff room. That’s what I did.

Update: Jul-23-2010
If you do the Update References thing and you don’t see your new Web Method, check the WebServices Properties by right-clicking on your Web Reference and going to ‘Properties’. Check out the URL for the Web Service and make sure it’s correct.

In my case the Properties had the URL of our PROD Web Service which didn’t help me much while I was adding a new method to the DEV Web Service. So I changed the PROD URL for the DEV URL and UpdateReference did its thing.

Advertisements

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: