今回はサンプルとして、引数なしの呼び出しに対して「Hello World」を返すRPC型のWebServiceを作成します。
以下のようなJavaプログラムを作成し、コンパイルします。
<< サンプルコード >>
package wsplab;
/**
* メッセージを返すRPC型サービス
*
* @return String メッセージ
*/
public class HelloWorld {
private String HELLO_MESSAGE = "Hello World";
public HelloWorld {
}
public String getMessage() {
return this.HELLO_MESSAGE;
}
}
注意) public属性を持つデフォルトコンストラクタの定義は必須です。
作成したclassファイルをWebアプリケーションのclassesディレクトリに登 録する。(copy HelloWorld.class C:\hpmw\wsp\webapps\hpws\WEB-INF\classes\wsplab)
<< コマンド >>ClassToWebService.bat [JavaClassName] [ServiceEndPointURL] [ServiceName]<< 実行コマンド >>ClassToWebService.bat wsplab.HelloWorld http://localhost:9090/hpws/soap/HelloWorldService HelloWorldService
正常に実行されると以下のメッセージが表示されます。
Generating WSDL for HelloWorldService Generating Service Registration File for HelloWorldService *********************************************************** To complete the deployment of HelloWorldService Make sure that the Java class wsplab.HelloWorld and its dependencies are in your classpath. You may use the 'classes' or 'lib' subdirectory under c:\hpmw\wsp\webapps\hpws\WEB-INF. ***********************************************************
(1)のコマンドが正常に実行されるとWSDLファイルおよびWebServiceコンフィグファイルが生成されます。
WSDLの確認:
http://localhost:9090/hpws/soap/HelloWorldService.wsdlにアクセスする。

C:\hpmw\wsp\webapps\hpws\webservicesにサービスが登録されます。
webservices --- 各サービスディレクトリ --- サービス名.xml
<< サービス登録ファイル >><?xml version="1.0" encoding="UTF-8" ?> <service-descriptor version="1.0"> <webservice adapter="rpc-java" wsdl-validation="false"> <param name="lookup-name" value="wsplab.HelloWorld"/> </webservice> </service-descriptor>
サービスの公開については、特別な操作は必要ありません。 ClassToWebService.batが正常に完了した時点でアクセス可能です。