JAX-WS 仕様の Glassfish Metro 実装を使用すると、実際に操作を呼び出すことなく、特定の操作の SOAP 要求メッセージを生成できます。WSDL のみに基づいてサンプル SOAP メッセージを生成する SOAPUI 機能のようなもので、操作用のパラメーターを提供して生成したいと考えています。
ありがとう。
JAX-WS 仕様の Glassfish Metro 実装を使用すると、実際に操作を呼び出すことなく、特定の操作の SOAP 要求メッセージを生成できます。WSDL のみに基づいてサンプル SOAP メッセージを生成する SOAPUI 機能のようなもので、操作用のパラメーターを提供して生成したいと考えています。
ありがとう。
わかった。私はそれを持っていると思います。それはきれいではなく、リフレクションを使用し、Oracle独自のクラスに基づいており、クライアント側のWS部分がすでに生成されていることを前提としているため、クリーンではありませんが、締め切りが避けられないような機能が必要な場合は、死そのものが私の話を聞いてくれます:)
// location of wsdl file provided in URL format
// ex. file://localhost/C:/wsdl.wsdl for local file
String wsdlLocation = "wsdlLocation";
try{
// we're assuming that you've already generated WS client side
GeneratedService service = new GeneratedService(
new URL(wsdlLocation),
new QName("namespaceURI", "localPart"));
GeneratedPort port = service.getGeneratedPort();
SEIStub stub = (SEIStub) Proxy.getInvocationHandler(port);
Field methodHandlersField =
stub.getClass().getDeclaredField("methodHandlers");
//hack to make private field accessible
methodHandlersField.setAccessible(true);
Method operationMethod = null;
Object args = null;
switch (somethingToTellYouWhatMethodToInvoke){
case someMethodValue:
operationMethod = GeneratedPort.class.getMethod(
"methodName", classes, of, your, attributes);
args = new Object[]{attributes, of, your, method};
break;
default:
throw new SomeException("some message");
break;
}
MethodHandler handler = ((Map<Method, MethodHandler>) methodHandlersField.
get(stub)).get(operationMethod);
Method createMessageMethod = handler.getClass().getSuperclass().
getDeclaredMethod("createRequestMessage", Object[].class);
//another hack
createMessageMethod.setAccessible(true);
Message message = (Message) createMessageMethod.invoke(handler, args);
Transformer transformer =
TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(
message.readPayloadAsSource(), new StreamResult(System.out));
} catch (Exception e){
//lots of things to catch
e.printStackTrace();
}
ですから、これもまた非常に悪い解決策ですが、何か重い思想家がやって来て、より良いもので私の一日を救うか、Sunがクラスを動かすまで、私はそれで十分でなければならないよりフレンドリーなパッケージにする必要があります。
DIY:ペイロードをダンプするPHPページをクライアントにポイントします。クライアントを実行します。応答の読み取りに失敗しますが、要求は保存されます。