Chapter 7: U2 Web Service Developer a. Open the runsoapserver.sh file using an editor.
b. Locate the following line: start javaw -classpath...
c.
Modify the command to the following: start javaw -Xms512m -Xmx1024m -classpath...
d. Save the file and then restart the SOAP server.
Note: The JVM startup parameters offer a variety of options for operating the JVM.
For details and a complete list of the available JVM startup parameters, refer to www.oracle.com
.
Defining web server listening IP addresses
Web servers listen when started on IP address 0.0.0.0, which allows clients outside of that server on the network to connect. It is sometimes necessary to restrict outside access to the server by changing the listening address to 127.0.0.1. By doing so, only the local server can connect to any port the web server has enabled.
This feature is only available on a deployed server and not from the U2 RESTful Web Service
Developer.
To change the web server IP address to 127.0.0.1, add
-Dloopbackonly=true to the startup script as shown in the following examples.
System
Windows
UNIX/Linux
Script name Script
runsoapserver.bat javaw.exe –Dloobackonly=true – classpath ...
runsoapserver.sh $JRE_DIR/$JRE_EXE –
Dloobackonly=true -Dfile ...
Sample Code
Creating a WSD web service
The instructions in this section uses two example BASIC programs and an XML file: XMLREPSUB,
SOAPXMLREPSUB, and ROCKET.XML
XMLREPSUB program
The XMLREPSUB program is a database subroutine that is called and used by the SOAP web service.
* For UniData use the following include.
* $INCLUDE INCLUDE XML.H
*
* Universe use the following include.
SUBROUTINE XMLRETSUB(P1,P2)
P2="Hello Rocket"
366
Creating a WSD web service
END
SOAPXMLRETSUB program
The SOAPXMLRETSUB program is the client-side BASIC subroutine that calls the SOAP web service using the SOAP API. It is used to test your SOAP web service.
***************************************************************
* SOAPXMLRETSUB
*
* For UniData use the following include.
* $INCLUDE INCLUDE XML.H
*
* Universe use the following include.
* $INCLUDE UNIVERSE.INCLUDE XML.H
*
* Example of Sending a ZIP SOAP 1.0 Request from BASIC
*
* SOAPXMLRETSUB - PROGRAM TO CALL a BASIC SUBROUTINE "XMLRETSUB" -
* using SOAP API (UniData 7.3.7, Universe 11.2.3)
* Sample program only, not intended for commercial use
* This program shows testing SOAP API request to a U2 WSD WEB SERVICE
* The XMLRETSUB subroutine called will return a "Hello Rocket" XML Page
*
* Turn on logging
* myfil = "c:\temp\SOAPXMLRETSUB.log"
RESULT=protocolLogging(myfil,"ON",10)
CRT "Logging started = ":RESULT
*
PROMPT ""
CRT
DISPLAY "U2 SOAP EXAMPLE"
*
URL = "http://den-l-aw01:8185/XMLRETSUB"
SoapAction="CALL_XMLRETSUB"
* SoapAction=""
Timeout = 60000
* Create the Request
Ret = SoapCreateRequest(URL , SoapAction , SoapReq)
IF Ret <> 0 THEN
STOP "Error in SoapCreateRequest: " : Ret
END
* inpfile = "ROCKET.XML"
* Set the content
Ret = soapSetRequestContent(SoapReq, inpfile, 0)
IF Ret <> 0 THEN
STOP "Error in SoapSetRequestContent: " : Ret
END
* Save request reqDoc="c:\u2\ud73\demo\soapxmlretsub.txt"
Ret=SOAPRequestWrite(SoapReq, reqDoc, 0)
IF Ret <> 0 THEN
STOP "Error in SoapRequestWrite: " : Ret
END
* PRINT "Request Content Status = ":SETREQUEST.STATUS
*
* Submit the Request
Ret = SoapSubmitRequest(SoapReq, Timeout, RespHeaders, RespData, SoapStatus)
IF Ret <> 0 THEN
367
Chapter 7: U2 Web Service Developer
CRT "Error in SoapSubmitRequest: " : Ret
STATUS=getSocketErrorMessage(Ret, errMsg)
CRT errMsg
STOP
END
*
PRINT "Response status : " : SoapStatus
PRINT "Response headers: " : RespHeaders
PRINT "Response data : " : RespData
*
RESULT=protocolLogging(myfil,"OFF",10)
CRT "Logging started = ":RESULT
ROCKET.XML file
The
ROCKET.XML file contains the request information needed by the SOAP web service. This file was created from the request information found in the Source section of the Web Services Explorer
WSDL Main utility. For more information on using the WSDL Main utility, see Starting the web service, on page 344 .
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://den-l-aw01" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:CALL_XMLRETSUB>
<q0:INP>hello</q0:INP>
</q0:CALL_XMLRETSUB>
</soapenv:Body>
</soapenv:Envelope>
1. Create a new SOAP server. For details on this, see Defining SOAP servers, on page 327 .
2. In the U2 Web Services pane, right-click the SOAP Servers node and then select
Add new server.
Enter the name of the new service name and then click
Next.
3. Enter the appropriate database connection properties and then click Next.
4. Enter the correct connection security information. Make sure that the URL parameter in the
SOAPXMLRETSUB subroutine matches that of the SOAP server and then click Next. For more information about the SoapCreateRequest function, see the U2 Basic Extensions.
5. Specify the correct Operation information. Add the name of the subroutine you want to call and specify the number of parameters in the subroutine. Click
Next to continue. The screen should look similar to the following example.
368
Creating a WSD web service
6. Specify the input and output parameters specified in the subroutine. The XMLRETSUB subroutine has two parameters: an input and an output. To add a new parameter, select Add and then add the parameter information in the Define Parameter dialog box, as shown in this example. See
Creating subroutine web services, on page 340
for more information.
7. Click Finish.
8. Start the web service. For details on starting the web service, see Starting the web service, on page 344
.
After running the example from the WSDL Main utility, you should see a response similar to the following:
Running the command from the command line gives an output similar to the following:
>LOGTO HS.SALES
>RUN BP SOAPXMLRETSUB
Logging started = 0
U2 SOAP EXAMPLE
Response status : 200²OK
Response headers: Jetty-Request²POST /XMLRETSUB HTTP/1.1■Date²Mon, 18 Aug 2014 1
4:20:09 GMT■Server²Jetty/4.2.x (Windows 7/6.1 x86 java/1.7.0_51)■Content-Type²te xt/xml; charset=utf-8■Content-Length²463
Response data : <?xml version="1.0" encoding="utf-8" ?><SOAP-ENV:Envelope xmlns:
SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schem as.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmln s:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header/><SOAP-ENV:Bo dy><ns1:CALL_XMLRETSUBResponse xmlns:ns1="http://den-l-aw01"><ns1:OUTP>Hello Roc ket</ns1:OUTP></ns1:CALL_XMLRETSUBResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
369
Chapter 7: U2 Web Service Developer
Logging started = 0
>
370