Here is my ultimate VM Options list for any Tomcat server I utilize.
-XX:MaxPermSize=512m -Xms512m -Xmx512m -Xss256k -XX:ReservedCodeCacheSize=512m
Pop this in before start up and one is virtually ensured not to experience any out of memory or perm gen space issues.
“Code on, and code strong”
What kind of Source Control is this community using? I’ll create a poll soon to see what us modern day developers are using. Stay tuned and stay checked in.
Netbeans and Apache Tomcat are used in this example to make a JSP client with the help of Apache SOAP toolkit (http://axis.apache.org/axis/). Assumption here is that you are bit familiar with JSP and NetBeans. Also, Apache Xerces (http://xerces.apache.org/) is used by the Java Client. The following jars are needed to run the Java Client successfully.
b) mailapi.jar (version 1.3 or later)
c) soap.jar (version 2.1 or later)
d) xercesImpl.jar (version 2.1.1 or later)
e) xml-apis.jar (should come bundled with the Apache Xerces download)
- Click on File–>New Project –>Choose “Java Web” –>Web Application
- Provide a Project Name and Location
- Set up Server Settings and then click on “Next”
- Disregard a Web App Framework for this tutorial and click on “Finish”
- Right click “Source Packages” and select “New” Java Package
- Name the package and click on “Finish”
- Reviewing our Java Client Web Application, the directory structure should look similar to this:
- Right click the Java Web App project and select “Properties” from the menu
- In the Project Properties window select “Libraries”. Click on “Add JAR/Folder” button
- Add activation.jar, mailapi.jar, soap.jar, xercesImpl.jar, and xml-apis Libraries to the Project
- Right click the JavaClient Project and select “New” –> Web Service Client…
- Configure the Web Service Client by Adding a WSDL URL (From .Net Web Service Step #7, paste the copied URL into the “New Web Service Client” WSDL URL field. Also, specify the package we created earlier to contain the generated java artifacts that will be created.
- After clicking on “Finish”, NetBeans will output information regarding the generated java artifacts. Aim for a “BUILD SUCCESSFUL” message
- Now that our Web Service Client has been created, go to the default NetBeans Java Client Web Application start page (index.jsp in this example) and right click within thetag. Select “Web Service Client Resources” –> Call Web Service Operation…
- Select the appropriate Web Service. Here we will go with “WebService” –> WebServiceSoap –> HelloWorld
- After clicking “OK”, NetBeans will auto-generate a snippet of code and inject that code within the jsp file.
- Running the Java Client will result in a successful call to the ASP .NET C# Web Service that we constructed earlier. One can see that the Result string matches the return value of the HelloWorld() method of the ASP .NET Web Service
- The DotNetWebService.HelloWorld() Web Method returns the string value that the Java Client Web App did. Great work!
This concludes the 2012 ASP .NET C# Web Service to Java Client consumption tutorial. May your Objects, Access, and Protocols be Simple and may your Web Services be RESTful for the next episode.
In this edition, we shall experiment with some cross platform dynamics. The goal of this 2 part series is for Java to talk to other platform web services. Sometimes as a java coder, you run into some web services that are done in WCF/SOAP. Rather than throw in the towel and quit, let’s figure out a way for them to communicate with each other.
First let’s venture over to the dark side and create a .NET C# Web Service.
Visual Studio automatically creates the necessary files and includes the needed references to support an XML Web service, to create a web services in C# in Visual Studio.NET.
- On the File menu. File->New->Project.
- In the New Project dialog box, select the visual C# Projects folder. Select the ASP.NET Web Application icon.
- Enter the Name of the Web Application and click OK to create the project. The New project will appear in the Solution Explorer.
- Right click the project name in the Solution Explorer, click “Add”, and then click “New Item”
- Within the “Add New Item” screen, select “Web”, and then scroll down to select the “Web Service” item. Give the Web Service a meaningful name and then click “Add” to continue.
- Specify the properties to WebService attribute. The namespace property you specify is used within the WSDL document of the Web service to uniquely identify the callable entry points of the service. Name is service name to display in help page. Description property of this attribute is included in the Service help page to describe the services usage. As shown in example here:Comment out or replace the default
[WebService] entry: [WebService(Namespace = "http://tempuri.org/")]With our new entry
[WebService(Namespace = "http://WebService", Name = "WebService", Description = "Test WebService by Johnny Coder")]
Also, one may edit the HelloWorld() return string to anything unique for this POC test.
- Run/Debug the Visual Studio Solution Project (F5) and the functional WebService default page should show up. Clicking on the “Service Description” link will send us to the URL which will be used later in the NetBeans Java Client portion of this tutorial.
- The Service Description URL should be copied and pasted for later.
- Now our web service is complete and ready to serve clients. We can consume the service from Java – stay tuned for the next episode in this series regarding cross platform Web Services and consuming clients -May your Objects, Access, and Protocols be Simple and may your Web Services be RESTful for the next episode.