Question
· Dec 29, 2019

%ListOfDataTypes limited to 50 characters.

I am trying to use the %ListOfDataTypes functionality, but am hitting a limit of 50 characters for each entry, when being used in a Web Service.  Is there a way to increase the number of characters that can be used in the %ListOfDataTypes through a web service? 

Discussion (7)0
Log in or sign up to continue

That would be if the property was defined as:

Property Test As list Of %String;

But in this case it's %Collection.ListOfDataTypes and not %ListOfDataTypes, which can save strings of arbitrary length by default.

Property Test As %ListOfDataTypes;

Simple test case:

Class Test.Col Extends %Persistent
{

Property Test As list Of %String;

Property Test2 As %ListOfDataTypes;

/// do ##class(Test.Col).Test()
ClassMethod Test(test2)
{
  set p = ..%New()
  set val = $tr($j("",100)," ", "a")
  if test2 {
    do p.Test2.Insert(val)
  } else {
    do p.Test.Insert(val)    
  }
  set sc = p.%Save()
  zw sc
}
}

I think that Robert Cemper has provided the answer, but I am not sure how to apply it to coding.

The goal of this exercise is to send a routine from the ^ROUTINE global on one computer to the ^RTN global on another computer through a web service. 

The following code is the web service code.

/// Routines.Upload
Class Routines.Upload Extends %SOAP.WebService [ ProcedureBlock ]
{

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

/// SOAP Namespace for the WebService
Parameter NAMESPACE = "http://www.bmirwin.com";

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

/// Receive Routines
Method RtnReceive(RtnName As %String, RtnLines As %ListOfDataTypes) As %String [ WebMethod ]
{
 Quit:RtnName="" "Failed"
 Kill ^RTN(RtnName)
 Set ^RTN(RtnName,0)=RtnLines.Count()
 For X=1:1:RtnLines.Count()
   { Set ^RTN(RtnName, X)=RtnLines.GetAt(X) }
 Quit "Done"
}

}

The following is the client that is just produced by importing the WSDL.

Class Routines.UploadSoap Extends %SOAP.WebClient [ ProcedureBlock ]
{

/// This is the URL used to access the web service.
Parameter LOCATION = "http://localhost:57773/csp/data1/Routines.Upload.cls";

/// This is the namespace used by the Service
Parameter NAMESPACE = "http://www.bmirwin.com";

/// Use xsi:type attribute for literal types.
Parameter OUTPUTTYPEATTRIBUTE = 1;

/// Determines handling of Security header.
Parameter SECURITYIN = "ALLOW";

/// This is the name of the Service
Parameter SERVICENAME = "Upload";

/// This is the SOAP version supported by the service.
Parameter SOAPVERSION = 1.1;

Method RtnReceive(RtnName As %String, RtnLines As %ListOfDataTypes(ELEMENTTYPE="%String",XMLITEMNAME="RtnLinesItem",XMLNAME="RtnLines")) As %String [ Final, ProcedureBlock = 1, SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{
 Quit ..WebMethod("RtnReceive").Invoke($this,"http://www.bmirwin.com/Routines.Upload.RtnReceive",.RtnName,.RtnLines)
}

}

Then the following is the code that I am using to call the web service.

RoutineOne(RtnName)
 New UCI,x,y,z,RtnLines
 Set UCI="VISTA"
 Quit:RtnName="" 0
 Quit:$Data(^[UCI]ROUTINE(RtnName))=0 0
 Set RtnLines=##class(%ListOfDataTypes).%New()
 For x=1:1:^[UCI]ROUTINE(RtnName,0,0)
   {
   Do RtnLines.Insert($Extract(^[UCI]ROUTINE(RtnName,0,x),1,50))
   }
 Set y=##class(Routines.UploadSoap).%New()
 Write RtnName,!
 ZW RtnLines
 Set z=y.RtnReceive(RtnName, RtnLines)
 Quit 1

the issue is here:

Method RtnReceive(RtnName As %String, 
  RtnLines As %ListOfDataTypes(ELEMENTTYPE="%String",
  XMLITEMNAME="RtnLinesItem",XMLNAME="RtnLines")) As %String [ Final, ProcedureBlock = 1, SoapBindingStyle = document, SoapBodyUse = literal, WebMethod ]
{

use instead ELEMENTTYPE="%VarString",

 %VarString inherits from %String all except pre-define MAXLEN=50

Thanks to Robert Cemper for the answer.  However, I misunderstood that Robert was saying, but it fixed the issue.

My web service original was the following:

Method RtnReceive(RtnName As %String, RtnLines As %ListOfDataTypes) As %String [ WebMethod ]

At misunderstanding Robert's suggestion I changed the code to the following:

Method RtnReceive(RtnName As %String, RtnLines As %ListOfDataTypes(ELEMENTTYPE="%String", XMLITENAME=RtnLinesItem", XMLNAME="RtnLines")) As %String [ WebMethod ]

I had used the $Extract to limit the line length to 50 to avoid the error, and now with the change I have removed the length limit and all is working.

To see an example of how this is going to be used see the following website:  www.bmirwin.com

The pages currently in this link are created on a local machine and SFTP'ed to the server using the Cache SFTP functionality.  Now with the web service functionality, these files can be pushed through the web service without first creating files.  This might work faster; that is the goal.