![]() ![]() ![]() ![]() |
警告 : | これらの機能は、JAX-RPC 1.1 ベースの Web サービスに対してのみ実装可能です。JAX-WS 2.0 Web サービスに対しては実装できません。 |
ここまでの各節では、WebLogic Web サービスの非同期機能 (Web サービスの信頼性のあるメッセージング、会話、非同期の要求と応答、およびバッファリング) を単独で使用する方法を説明してきました。しかし通常、Web サービスではこれらの機能を併用しています。例については、「信頼性のある会話形式の Web サービスを実装する JWS ファイルの例」および「信頼性のある会話形式の Web サービスを非同期で呼び出すクライアント Web サービスの例」を参照してください。
併用すると、個々の機能についての節で説明した制限事項の一部が適用されなくなったり、場合によっては追加の制限事項が適用されたりします。
ソース WebLogic Server インスタンス上で JMS キューを作成する際には、weblogic.wsee.DefaultQueue
の JNDI 名を指定することが要求されます。キューの名前は任意に付けることができます。また、この JMS キューが「ローカル」であることも必ず指定してください。通常は、ローカル JNDI 名を設定することで指定できます。
@Oneway
アノテーションを付けることはできません。AsyncPreCallContext
または AsyncPostCallContext
) にプロパティを設定する場合、そのプロパティは、java.io.Serializable
を実装している必要があります。@ServiceClient
JWS アノテーションを使用する必要があります。 WLStub.CONVERSATIONAL_METHOD_BLOCK_TIMEOUT
を設定する場合、クライアントはブロックを行わないので、プロパティは無視されます。@Oneway
アノテーションでマークされていないものである必要があります。WebServiceA
が会話形式であり、これが非同期の要求と応答を使用して WebServiceB
を呼び出すとします。WebServiceA
が会話形式なので、WebServiceB
からの非同期応答もまた、同じ会話に参加することになります。
次のサンプルの JWS ファイルでは、信頼性があり、かつ会話形式でもある Web サービスを実装しています。
package examples.webservices.async_mega;
import java.io.Serializable;
import weblogic.jws.WLHttpTransport;
import weblogic.jws.Conversation;
import weblogic.jws.Policy;
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService(name="AsyncMegaPortType",
serviceName="AsyncMegaService",
targetNamespace="http://examples.org/")
@Policy(uri="AsyncReliableConversationPolicy.xml",
attachToWsdl=true)
@WLHttpTransport(contextPath="asyncMega",
serviceUri="AsyncMegaService",
portName="AsyncMegaServicePort")
/**
* 信頼性があり、かつ会話形式でもある Web サービス
*/
public class AsyncMegaServiceImpl implements Serializable {
@WebMethod
@Conversation (Conversation.Phase.START)
public String start() {
return "Starting conversation";
}
@WebMethod
@Conversation (Conversation.Phase.CONTINUE)
public String middle(String message) {
return "Middle of conversation; the message is: " + message;
}
@WebMethod
@Conversation (Conversation.Phase.FINISH)
public String finish(String message ) {
return "End of conversation; the message is: " + message;
}
}
次の JWS ファイルでは、「信頼性のある会話形式の Web サービスを実装する JWS ファイルの例」に記載の Web サービスにおけるさまざまな会話形式のメソッドを確実に呼び出すクライアント Web サービスの実装方法を示します。クライアント JWS ファイルでは、非同期の要求と応答機能も使用しています。
package examples.webservices.async_mega;
import weblogic.jws.WLHttpTransport;
import weblogic.jws.ServiceClient;
import weblogic.jws.AsyncResponse;
import weblogic.jws.AsyncFailure;
import javax.jws.WebService;
import javax.jws.WebMethod;
import weblogic.wsee.async.AsyncPreCallContext;
import weblogic.wsee.async.AsyncCallContextFactory;
import weblogic.wsee.async.AsyncPostCallContext;
import examples.webservices.async_mega.AsyncMegaPortType;
import examples.webservices.async_mega.AsyncMegaService;
import examples.webservices.async_mega.AsyncMegaService_Impl;
import java.rmi.RemoteException;
@WebService(name="AsyncMegaClientPortType",
serviceName="AsyncMegaClientService",
targetNamespace="http://examples.org/")
@WLHttpTransport(contextPath="asyncMegaClient",
serviceUri="AsyncMegaClient",
portName="AsyncMegaClientServicePort")
/**
* AsyncMegaService との間で信頼性を伴い非同期に会話するクライアント
* Web サービス
*/
public class AsyncMegaClientImpl {
@ServiceClient(
wsdlLocation="http://localhost:7001/asyncMega/AsyncMegaService?WSDL",
serviceName="AsyncMegaService",
portName="AsyncMegaServicePort")
private AsyncMegaPortType port;
@WebMethod
public void runAsyncReliableConversation(String message) {
AsyncPreCallContext apc = AsyncCallContextFactory.getAsyncPreCallContext();
apc.setProperty("message", message);
try {
port.startAsync(apc);
System.out.println("start method executed.");
port.middleAsync(apc, message );
System.out.println("middle method executed.");
port.finishAsync(apc, message );
System.out.println("finish method executed.");
catch (RemoteException e) {
e.printStackTrace();
}
}
@AsyncResponse(target="port", operation="start")
public void onStartAsyncResponse(AsyncPostCallContext apc, String message) {
System.out.println("-------------------");
System.out.println("Got message " + message );
System.out.println("-------------------");
}
@AsyncResponse(target="port", operation="middle")
public void onMiddleAsyncResponse(AsyncPostCallContext apc, String message) {
System.out.println("-------------------");
System.out.println("Got message " + message );
System.out.println("-------------------");
}
@AsyncResponse(target="port", operation="finish")
public void onFinishAsyncResponse(AsyncPostCallContext apc, String message) {
System.out.println("-------------------");
System.out.println("Got message " + message );
System.out.println("-------------------");
}
@AsyncFailure(target="port", operation="start")
public void onStartAsyncFailure(AsyncPostCallContext apc, Throwable e) {
System.out.println("-------------------");
e.printStackTrace();
System.out.println("-------------------");
}
@AsyncFailure(target="port", operation="middle")
public void onMiddleAsyncFailure(AsyncPostCallContext apc, Throwable e) {
System.out.println("-------------------");
e.printStackTrace();
System.out.println("-------------------");
}
@AsyncFailure(target="port", operation="finish")
public void onFinishAsyncFailure(AsyncPostCallContext apc, Throwable e) {
System.out.println("-------------------");
e.printStackTrace();
System.out.println("-------------------");
}
}
![]() ![]() ![]() |