views:

79

answers:

2

So, I'm trying to use soap to communicate with a webservice and getting errors. What is frustrating about this particular issue is that it works perfectly fine with my local copy of the webservice (yes, I tried turning off my firewall) and used to work fine with a previous version of the webservice and client. I suspect I could (though I'll have to look up how to do this) add an action parameter to what the client is sending. However, I am very curious why it was able to work previously without one.

Edit Clarification: I think the relevant code was the same between when it stopped working and when it worked (since I checked against an old version of the program and had the same problems and the relevant code was the same...unless I missed something subtle). I know the actual server program is the same on both the local copy and the remote copy, even though it only works locally. I thus suspect there is some sort of weird configuration setting I can change to make it work.

Error message: "soap:ClientUnable to handle request without a valid action parameter. Please supply a valid soap action."

VB Client Code

'WEB_SERVICE_URL_CONST = http://site.com/foo.asmx
'domDoc.xml = <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;TestConnection xmlns="http://site.com"/&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;

Dim oXml As New XMLHTTPRequest
oXml.Open "POST", WEB_SERVICE_URL_CONST, False, "\"
oXml.setRequestHeader "Content-Type", "text/xml"
oXml.send domDoc.xml

C# Server Code

[WebMethod]
        public int TestConnection()
        {
            return 1;
        }
A: 

Are you sure the first two lines are not commented-out in the real version? The sample code seems to have no value for WEB_SERVICE_URL_CONST and domDoc.xml, and an empty Soap request would indeed not specify any action?

EDIT: I find the "used to work fine with a previous version of the webservice and client" a bit confusing. If you actually changed both the client and the server, then what part did not change?

Arjan
The commented out lines don't exist in the real version: They were added to provide context that the sample code does not provide. I verified that the values were what I say they were at runtime, though the urls in both places are fake.
Brian
A: 

The problem was with the xmlns="http://site.com" code. When I tested locally, I was using xmlns="http://localhost" by mistake. In fact, this should not be changed on the client or the server (in the server, this would be WebService(Namespace =...)), regardless of where I am testing...but if it does change, the client and server need to match.

Brian