I created a simple ATL Web Service that accepts a string and returns the string reversed.
The code is a shown below:
--------------------------
----------
----------
----------
----------
----------
----------
----------
-----
// ReverseString.h : Defines the ATL Server request handler class
//
#pragma once
namespace ReverseStringService
{
// all struct, enum, and typedefs for your webservice should go inside the namespace
// IReverseStringService - web service interface declaration
//
[
uuid("8B57749E-80D9-4A18-9
6E4-F39E0D
BEE610"),
object
]
__interface IReverseStringService
{
[id(1)] HRESULT ReverseString([in] BSTR bstrInput, [out, retval] BSTR *bstrOutput);
};
// ReverseStringService - web service implementation
//
[
request_handler(name="Defa
ult", sdl="GenReverseStringWSDL"
),
soap_handler(
name="ReverseStringService
",
namespace="urn:ReverseStri
ngService"
,
protocol="soap"
)
]
class CReverseStringService :
public IReverseStringService
{
public:
// This is a sample web service method that shows how to use the
// soap_method attribute to expose a method as a web method
[ soap_method ]
HRESULT ReverseString(/*[in]*/ BSTR bstrInput, /*[out, retval]*/ BSTR *bstrOutput)
{
// Check the outgoing pointer...
if ( bstrOutput == NULL ) return E_POINTER;
// Reverse the characters
*bstrOutput = SysAllocString(_wcsrev(bst
rInput));
return S_OK;
}
// TODO: Add additional web service methods here
}; // class CReverseStringService
} // namespace ReverseStringService
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
--
The code that consumes the Web services is in C# is as follows:
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
using System;
using ReverseStringClient.localh
ost;
namespace ReverseStringClient
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
// Create an instance of the ATL Server's
// Web Service proxy
ReverseStringService ws = new ReverseStringService();
string strResult = ws.ReverseString("This is a test!");
Console.WriteLine("The resulting string was '{0}'",strResult);
}
}
--------------------------
----------
----------
----------
----------
----------
-
The Web Reference is set to
http://localhost/ReverseString/ReverseString.dll?Handler=GenReverseStringWSDLI am running the Web Service in IIS 5.0 on Win2k Advanced Server.
--------------------------
----------
----------
----------
----------
----------
--
When I try and consume the web service I am getting the error below:
--------------------------
----------
----------
----------
----------
----------
---
"An unhandled exception of type 'System.Net.WebException' occurred in system.web.services.dll "Additional information: The request failed with HTTP status 405: Method not allowed."
--------------------------
----------
----------
----------
----------
----------
I know that HTTP status 405: Method Not Allowed error is raised when the method specified in the Request-Line is not allowed for the resource identified by the Request-URI. I have checked all my settings on IIS they seem to be correct. I don't how to progress further.Could anyone please help
Start Free Trial