Question
· Jun 4, 2018

How to add an underscore to WebMethod name

Hi, guys,

One of my clients was required by the hospital to name their webservice operation as Action_Subject, ie. Get_PatientInfo

When I define the web method as "Get_PatientInfo" as below,

/// MyApp.MyService
Class MyApp.MyService Extends %SOAP.WebService [ ProcedureBlock ]
{

/// Name of the WebService.
Parameter SERVICENAME = "MyService";

/// TODO: change this to actual SOAP namespace.
/// SOAP Namespace for the WebService
Parameter NAMESPACE = "http://tempuri.org";

/// Namespaces of referenced classes will be used in the WSDL.
Parameter USECLASSNAMESPACES = 1;

/// TODO: add arguments and implementation.
/// Test
Method "Get_PatientInfo"() As %String [ WebMethod ]
{
    Quit "Test"
}

}

the code can not be compiled because of the following error:

Compilation started on 06/04/2018 12:48:09 with qualifiers 'cuk /checkuptodate=expandedonly'
Compiling class MyApp.MyService
ERROR #5802: Datatype validation failed on property '%Dictionary.ClassDefinition:IsValid', with value equal to "MyApp.MyService.Get_PatientInfo"
  > ERROR #5802: Datatype validation failed on property '%Dictionary.ClassDefinition:Name', with value equal to "MyApp.MyService.Get_PatientInfo"
    > ERROR #5490: Error running generator for method 'OnCompile:MyApp.MyService' 
ERROR: %SOAP.WebBase.cls(OnCompile) of generated code compiling subclass 'MyApp.MyService'
      > ERROR #5030: An error occurred while compiling class 'MyApp.MyService'
Compiling routine MyApp.MyService.1

If we can not name the method as required, is there any other way to do that? Thanks.

Discussion (4)1
Log in or sign up to continue

Thanks Eduard. But not exactly.

With the use of SoapAction, we can rename the soapAction attribute as below:

<binding name="MyServiceSoap" type="s0:MyServiceSoap">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>

<operation name="GetPatientInfo">

<soap:operation soapAction="Get_PatientInfo" style="document"/>

<input><soap:body use="literal"/></input>

<output><soap:body use="literal"/></output>

</operation>

</binding>

What they want is actually to change the name of the operation.

Hi,
underscore in method names are *not* supported and possible, I am afraid.

Besides the SoapAction already mentioned by Eduard you can try if adjusting the SoapMessageName and SoapRequestMessage keywords
at the method level in your WebService are helping to get what you want.

Here is an example:

Method AddInteger(Arg1 As %Integer = 0, Arg2 As %Integer = 0) As %Integer [ SoapAction = Add_Integer, SoapMessageName = Add_Integer_Response, SoapRequestMessage = Add_Integer, WebMethod ]
{
  Quit Arg1 + Arg2
}

HTH,

Bernd