RE: Async services
"Ockleford Paul (NHS CONNECTING FOR HEALTH)" <[email protected]>
| Newsgroups | gmane.text.xml.axis.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, I am still pretty much stuck with getting these services to work. I have been trying to replicate the code from some example source that I found online and as far as I can see I have created everything I should need but I am still getting errors..
Even trying to expose my services causes this error: org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: sun.reflect.generics.reflectiveObjects.WildcardTypeImpl
The examples all seem to expose a method with a return type of Future<?> without any problems but when I try this axis errors and then fails to deploy the service.
I really need to know where I am going wrong with this because I am completely out of ideas and I have read just about every web page I can find related to creating asynchronous services and I still can't get it to work, the examples make it look easy but there must be something I missing.
I have pasted in the code I now have below but does anybody have a working example of some asynchronous services along with the services.xml file to deploy the service that they could provide me?
Code:
Service interface:
public interface CreditScoreService {
//Async with passed in callback function
@ResponseWrapper(localName = "creditScoreResponse",
targetNamespace = "http://webservices2.CreditScoreResponse",
className = "webservices2.CreditScoreResponse")
@RequestWrapper(localName = "creditScore", targetNamespace = "http://webservices2.CreditScore", className = "webservices2.CreditScore")
@WebMethod(operationName = "getCreditScore")
public Future<?> getCreditScoreAsync(@WebParam(name = "requestType",
targetNamespace = "http://webservices2")
String requestType,
@WebParam(name = "asyncHandler", targetNamespace = "")
AsyncHandler<CreditScoreResponse> handler);
//Async using polling
@ResponseWrapper(localName = "creditScoreResponse",
targetNamespace = "http:// webservices2.CreditScoreResponse",
className = "webservices2.CreditScoreResponse")
@RequestWrapper(localName = "creditScore",
targetNamespace = "http://webservices2.CreditScore",
className = "webservices2.CreditScore")
@WebMethod(operationName = "getCreditScore")
public Response<CreditScoreResponse> getCreditScoreAsync(@WebParam(name = "requestType",
targetNamespace = "http://webservices2") String requestType);
//Standard method
@ResponseWrapper(localName = "creditScoreResponse",
targetNamespace = "http:// webservices2.CreditScoreResponse",
className = " webservices2.CreditScoreResponse")
@RequestWrapper(localName = "creditScore",
targetNamespace = "http://webservices2.CreditScore",
className = "webservices2.CreditScore")
@WebResult(name = "responseType",
targetNamespace = "http:// webservices2")
@WebMethod
public String getCreditScore(String inParam);
}
Service interface implementation:
public class CreditScoreServiceImpl implements CreditScoreService {
public Response<CreditScoreResponse> getCreditScoreAsync(String requestType) {
System.out.println("In getCreditScoreAsync 1");
return null;
}
public Future<?> getCreditScoreAsync(String requestType, AsyncHandler<CreditScoreResponse> handler) {
System.out.println("In getCreditScoreAsync 2");
return null;
}
public String getCreditScore(String inputParam) {
try {
Thread.sleep(100000);
} catch(Exception e) {
e.printStackTrace();
}
return "200";
}
}
Credit Score object:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"requestType"
})
@XmlRootElement(name = "creditScore")
public class CreditScore {
@XmlElement(namespace = "http:// webservices2.CreditScore", required = true)
protected String requestType;
/**
* Gets the value of the requestType property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRequestType() {
return requestType;
}
/**
* Sets the value of the requestType property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRequestType(String value) {
this.requestType = value;
}
}
Credit Score Response:
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"responseType"
})
@XmlRootElement(name = "creditScoreResponse")
public class CreditScoreResponse {
@XmlElement(required = true)
protected String responseType;
/**
* Gets the value of the responseType property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getResponseType() {
return responseType;
}
/**
* Sets the value of the responseType property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setResponseType(String value) {
this.responseType = value;
}
}
Finally my services.xml (I have left in the commented out sections as hopefully someone can comment on what I have been trying..):
<serviceGroup>
<service name="CreditScoreService">
<description>Test Async Service</description>
<parameter name="ServiceClass" locked="false">webservices2.CreditScoreService</parameter>
<!--<operation name="getCreditScoreAsync">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCInOutAsyncMessageReceiver" />
</operation>-->
<!--<operation name="getCreditScore">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCInOutAsyncMessageReceiver" />
</operation>-->
</service>
</serviceGroup>
From: Martin Gainty [mailto:[email protected]]
Sent: 05 December 2012 19:55
To: [email protected]
Subject: RE: Async services
Hi Paul
the shortest path to achieving an Impl Class is to code your own Impl Concrete class of the interface
you can also use a Factory ..but..to code a Factory Implementation is not trivial as a Factory is required to 'divine' all the necessary attributes and construct methods
to construct an Implementation Class with 'reasonable' default values for all attributes
do you see a need for a Factory Class to implement a concrete Impl class for an interface specified in the parameter name="ServiceClass"
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
________________________________
From: [email protected]
To: [email protected]
Date: Wed, 5 Dec 2012 16:22:00 +0000
Subject: RE: Async services
I thought I might as well add the code that I have for trying to get this to work as I might get some better help that way:
If I don't use the interface in the services.xml but instead use the implementation I no longer get the error related to a return type of Future<?>
Services.xml:
<serviceGroup>
<service name="CreditScoreService">
<description>Test Async Service</description>
<parameter name="ServiceClass" locked="false"> webservices2.CreditScoreServiceImpl</parameter>
<operation name="getCreditScore">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
</serviceGroup>
public interface CreditScoreService {
//Async with passed in callback function
public Future<?> getCreditScoreAsync(String inParam, AsyncHandler<String> handler);
//Async using polling
public Response<String> getCreditScoreAsync(String inParam);
//Standard method
public String getCreditScore(String inParam);
}
public class CreditScoreServiceImpl implements CreditScoreService {
public Response<String> getCreditScoreAsync(String requestType) {
System.out.println("calling async method");
return null;
}
public Future<String> getCreditScoreAsync(String requestType, AsyncHandler<String> handler) {
System.out.println("calling async method");
return null;
}
public String getCreditScore(String inputParam) {
return "200";
}
public class CreditScoreResponse {
private String responseType;
/**
* @return the responseType
*/
public String getResponseType() {
return responseType;
}
/**
* @param responseType the responseType to set
*/
public void setResponseType(String responseType) {
this.responseType = responseType;
}
}
}
Can anyone can tell me where I am going wrong, please!
Thanks,
Paul
From: Ockleford Paul (NHS CONNECTING FOR HEALTH) [mailto:[email protected]]
Sent: 05 December 2012 15:10
To: [email protected]
Subject: Async services
---
This message was sent from an email address external to NHSmail but gives the appearance of being from an NHSmail (@nhs.net) address. The recipient should verify the sender and content before acting upon information contained within.
The identified sender is [email protected]
---
Hi,
I am trying to create a service which exposes asynchronous methods in the same way as this document describes: http://axis.apache.org/axis2/java/core/docs/jaxws-guide.html#Async
I am having quite a lot of trouble getting either of the examples to work., even trying to expose a method with a return type of Future<?> seems to result in an error when axis starts up.
My first question is where can I download the source code related to the snippets, it would be nice to be able to see the implementation of the methods described in the interface.
Second question is whether anybody has a link to a good document that details this process. I have tried to follow quite a few tutorials today and have still not ended up with a working demo.
Finally does the method described on the axis website work for stub code generated from a wsdl? I don't seem to be able to get a handle on my CreditScoreService object like the example client shows so I have no idea how to actually get a Request object back.
Any help would be good as I am currently stuck on this.
Thanks,
Paul
********************************************************************************************************************
This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.
Thank you for your co-operation.
NHSmail is the secure email and directory service available for all NHS staff in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and GSi recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
********************************************************************************************************************
********************************************************************************************************************
This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.
Thank you for your co-operation.
NHSmail is the secure email and directory service available for all NHS staff in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and GSi recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
********************************************************************************************************************
********************************************************************************************************************
This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.
Thank you for your co-operation.
NHSmail is the secure email and directory service available for all NHS staff in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information with NHSmail and GSi recipients
NHSmail provides an email address for your career in the NHS and can be accessed anywhere
********************************************************************************************************************