私はいくつかの「システム」からWebサービスを利用することに取り組んでいます。Apache Axis2 を使用して Web サービス クライアントを作成しました。
今、私は1つの状況で立ち往生しています
1) このクライアントを Java コンソール ベースのアプリケーションでテストしている場合、問題なく動作しています。
LogonRequestDocument logonRequestDoc = LogonRequestDocument)getTestObject(LogonRequestDocument.class);
ここでLogonRequestDocument
は、Interface,
getTestObject()
メソッドは次のように実装されます。
public org.apache.xmlbeans.XmlObject getTestObject(java.lang.Class type) throws java.lang.Exception {
java.lang.reflect.Method creatorMethod = null;
if (org.apache.xmlbeans.XmlObject.class.isAssignableFrom(type)) {
Class[] declaredClasses = type.getDeclaredClasses();
for (int i = 0; i < declaredClasses.length; i++) {
Class declaredClass = declaredClasses[i];
if (declaredClass.getName().endsWith("$Factory")) {
creatorMethod = declaredClass.getMethod("newInstance", null);
break;
}
}
}
if (creatorMethod != null) {
return (org.apache.xmlbeans.XmlObject) creatorMethod.invoke(null, null);
} else {
throw new java.lang.Exception("Creator not found!");
}
}
ここで、creatorMethod.invoke(null,null)
メソッドは Java コンソール アプリケーションでは問題なく動作しますが、同じコードを Web アプリケーションで使用すると例外がスローされます。
Axis2 を使用する Java のコンソールと Web アプリの両方に違いがあるかどうかを知りたいです。
コンソール アプリケーションを使用すると、これgetTestObj()
は正常に機能し、例外は発生しませんが、同じコードを Web アプリケーションで使用すると、ExceptionInInitializerError
このメソッドによって引き起こされた初期化が失敗すると、この例外が発生します。
Web サービスの準備と使用を正しく実装するための支援が必要です。