Search code examples
.netsoapasmx

Is it possible to override a SOAP action namespace for one particular method?


I'm making some changes in an existing WebServices made in VB.NET/ASMX. The previous programmer put his company's URL as namespace. Now, I'm developing it, and I work for other company. I'd like that my new method doesn't show "Company 1 URL". How can I do that without breaking any consumer of the existing methods? What I did, didn't work.

C# answers are welcome.

<System.Web.Services.WebService(Namespace:="http://company1.com/MyService")>
Public Class Service

  <WebMethod()>
  Public Function Method1() As String
      Return "method 1"
   End Function

   <WebMethod()>
   <SoapMethod(XmlNamespace:="http://wwww.my-client-url.com")>
   Public Function Method2() As String
       Return "method 2"
   End Function

Solution

  • I found what I was looking for. It was the SoapDocumentMethod attribute. Here's how to use it

    <SoapDocumentMethod(RequestNamespace:="http://company.com/ServiceName",
                        ResponseNamespace:="http://company.com/ServiceName",                             
                        Action:="http://company.com/ServiceName/Method2")>
      Public Function Method2() As String
         Return "method 2"
      End Function