uCosminexus Application Server, Web Service Development Guide
Create the Web Service Implementation Class that codes the processing of the Web Service. In this subsection, you calculate the contents of the received request message and create the Web Service Implementation Class that returns the response message.
The following is an example of the creation of a Web Service Implementation Class:
package com.sample;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlAttachmentRef;
import javax.activation.DataHandler;
@javax.jws.WebService(serviceName="UserInfoService",targetNamespace="http://sample.com")
public class UserInfoImpl{
public UserData getUserData( String in0,
@XmlAttachmentRef javax.activation.DataHandler in1 )
throws UserInfoException{
//Processing-for-registering-the-photograph-into-the-employee-information
...
UserData userdata = new UserData();
//Set-up-the-registered-employee-name-and-affiliation
if ( in0.equals("1") )
{
userdata.setName("Hitachi Taro");
userdata.setSection("The personnel section");
} if (...) {
...
} ...
//Set-up-the-confirm-registration-message
if ( in1 == null )
{
userdata.setMessage("Failure(no image).");
} else {
userdata.setMessage("Success.");
}
return userdata;
}
}
|
The created UserInfoImpl.java is stored in c:\temp\jaxws\works\attachments\server\src\com\sample\directory with the UTF-8 format.
The user-defined type class com.sample.UserData used in com.sample.UserInfoImpl is also created. Normally, the creation of the user-defined type class is optional, but a user-defined type class will be created here.
The following is an example of the creation of a user-defined type class:
package com.sample;
public class UserData{
private java.lang.String message;
private java.lang.String name;
private java.lang.String section;
public UserData(){
}
public java.lang.String getMessage() {
return this.message;
}
public void setMessage(java.lang.String message) {
this.message = message;
}
public java.lang.String getName() {
return this.name;
}
public void setName(java.lang.String name) {
this.name = name;
}
public java.lang.String getSection() {
return this.section;
}
public void setSection(java.lang.String section) {
this.section = section;
}
}
|
The created UserInfoImpl.java is stored in c:\temp\jaxws\works\attachments\server\src\com\sample\directory with the UTF-8 format.
The exception class com.sample.UserInfoException thrown in com.sample.UserInfoImpl is also created. Normally, the creation of the exception class is optional, but an exception class will be created here.
The following is an example of the creation of an exception class:
package com.sample;
public class UserInfoException extends Exception {
String detail;
public UserInfoException (String message, String detail) {
super (message);
this.detail = detail;
}
public String getDetail () {
return detail;
}
}
|
The created UserInfoException.java is stored in c:\temp\jaxws\works\attachments\server\src\com\sample\directory with the UTF-8 format.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.