uCosminexus Application Server, Web Service Development Guide
Create an implementation class for the Web Service client that uses the Web Service.
The following is an example for creating a Web Service client that invokes Web Services once:
package com.sample.client;
import java.awt.Image;
import java.io.File;
import javax.imageio.ImageIO;
import javax.xml.ws.soap.MTOMFeature;
import com.sample.UserInfoImpl;
import com.sample.UserData;
import com.sample.UserInfoService;
import com.sample.UserInfoException_Exception;
public class TestClient {
public static void main( String[] args ) {
try {
// Generate image object
File imageFile = new File("portrait.png");
if (!imageFile.exists()) {
throw new RuntimeException("Cannot find the file \"portrait.png\".");
}
Image image = ImageIO.read(imageFile);
UserInfoService service = new UserInfoService();
UserInfoImpl port = service.getUserInfoImplPort(new MTOMFeature());
UserData userdata = port.getUserData("1", image);
System.out.print("[RESULT] " + userdata.getMessage());
System.out.println(" Name:" + userdata.getName()
+ ", Section:" + userdata.getSection());
} catch(UserInfoException_Exception e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}
|
The created TestClient.java is stored in the c:\temp\jaxws\works\mtom\client\src\com\sample\client\ directory in UTF-8 format.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.