4

We have a site running on MOSS 2007 which makes calls to custom web service asmx methods on the same domain from the client.

At first everything works fine, but after a bit of time has passed the service will start to fail with:

[domain]/_layouts/error.aspx?ErrorText=Request format is unrecognized for URL unexpectedly ending in %27%2FIsSuspectWaterLevel%27.

Interestingly enough [domain]/_vti_bin/Custom/CustomFunctionality.asmx?op=IsSuspectWaterLevel is still available, but a call to [domain]/_vti_bin/Custom/CustomFunctionality.asmx/IsSuspectWaterLevel will fail as described.

We've found that "touching" C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\ISAPI\ web.config will bring the webservice back to life.

The asmx file lives at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\ECan\MyECan_ComplianceWaterUsage.asmx

Any ideas of what might be going on here and how to resolve them?

Some extra detail:

App pool settings in case they're useful: http://i51.tinypic.com/x51qw.png

The following web.config settings are present in the root and sub directory hosting the asmx:

  <system.web>
    <webServices>
      <protocols>
        <add name="HttpSoap" />
        <add name="HttpGet" />
        <add name="HttpPost" />
      </protocols>
    </webServices>
  ...
  </system.web>

We are calling the web service from javascript (jQuery). I've checked all the settings mentioned in this link and all match. I think calling from javascript may not be the culprit though as going directly to

[domain]/_vti_bin/Custom/CustomFunctionality.asmx/IsSuspectWaterLevel

with parameters supplied also fails with the same error - no javascript involved. Failing after a short period of time has passed, but works fine when web.config has just been "touched" again.

Thanks in advance for any help! Cheers, Gavin

8
  • If you are going to cross post, at least have the decency to include all data in the question asked and not linking to your cross posts for details. Really... Closed the question until this is fixed. Ask a mod if you want it re-opened after this is fixed. Commented Jul 20, 2011 at 22:14
  • Hi Anders, sorry for that - made suggested changes. How do I get a mod to re-open the post? cheers.
    – Gavin
    Commented Jul 20, 2011 at 22:28
  • Thanx! q reopened... Commented Jul 20, 2011 at 22:32
  • 1
    according to your settings, when the web.config is "touched", it fires a recycle of the App Pool. So it's the recycling of the App Pool which makes your app works again. You should check the SharePoint logs to see if nothing fails
    – GillouX
    Commented Jul 21, 2011 at 12:19
  • Thanks for the suggestion GillouX. Scanning through the logs and searching against various related function names etc. doesn't yield any obvious results. I'm wondering if it's something to do with a url parsing module(?) of some flavor somewhere failing though as I can get to CustomFunctionality.asmx but not CustomFunctionality.asmx/IsSuspectWaterLevel
    – Gavin
    Commented Jul 21, 2011 at 22:09

2 Answers 2

0

An inelegant workaround to this issue that works for us: We've swapped out the web service asmx end point for a web handler ashx endpoint. This doesn't suffer the same issue for some reason.

I'm guessing from this that there's some issue creeping in after a period of time which is causing urls to resolve incorrectly. I suspect that the / after the .asmx in the url is the curprit. The ashx endpoint implemented is working purely on url parameters and posted data.

Obviously this work around won't always be an option for others who might experience the same issue as we're loosing a lot of the rich web service functionality that's pre-baked in to an asmx endpoint.

Unfortunately I won't be able to test any other solutions that people might put forward from now on as we've moved away from the web service asmx approach. Sorry.

0

This error occurs since in SharePoint it is not supported to specify a request in the following format:

http://site/_vti_bin/webservice.asmx/operation 

The operation have to be specified using SOAP envelope message via POST request as demonstrated below.

How to consume SharePoint SOAP services using JavaScript

function getLists(complete)
{
    var soapEnv =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
            <soapenv:Body> \
                <GetListCollection xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                </GetListCollection> \
            </soapenv:Body> \
        </soapenv:Envelope>";

    $.ajax({
        url: _spPageContextInfo.webServerRelativeUrl + "_vti_bin/lists.asmx",
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: function(data){
            complete(processListsResults(data));
        },
        contentType: "text/xml; charset=\"utf-8\""
    });

    function processListsResults(data){
        var lists = {};
        $(data.responseXML).find("List").each(function() {
           lists[$(this).attr('Name')] = {
                'Title': $(this).attr('Title') 
           };
        }); 
        return lists;
    }
}

Usage

getLists(function(lists)
{
    for(var key in lists){
        console.log(lists[key].Title);
    }
});

References

Calling the SharePoint Web Services with jQuery

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.