Bonjour,
J'ai l'architecture de code suivante (voir miniature) et donc utilise PortletConsommateur.java comme client général de n'importe quel service dans
PortletServiceALaDemande.java .
Seul PortletServiceALaDemande est extends de GenericPortlet
Voici la fonction me permettant de consommer un service dans PortletConsommateur.java :
Et lorsque je veux transformer tous ce beau petit monde en war,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 public String consommer(String endPoint_ , String endpointUrl, String service_ , String portName_, String cutPortName_,String action_, String[][] Action_param){ URL wsdlLocation = null; try { wsdlLocation = new URL(endPoint_); // cxf } catch (MalformedURLException e) { e.printStackTrace(); } QName serviceName = new QName(portName_, service_); QName portName = new QName(portName_, service_+"Port"); Service service = Service.create(serviceName); service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl); /** Create a Dispatch instance from a service.**/ Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE); /** Create SOAPMessage request. **/ // compose a request message MessageFactory mf; try { mf = MessageFactory.newInstance(); // Create a message. This example works with the SOAPPART. SOAPMessage request = mf.createMessage(); SOAPPart part = request.getSOAPPart(); // Obtain the SOAPEnvelope and header and body elements. SOAPEnvelope env = part.getEnvelope(); SOAPHeader header = env.getHeader(); //env.setAttribute("xmlns:cal", "http://calcul/"); SOAPBody body = env.getBody(); QName ns = new QName(portName_, action_, cutPortName_); SOAPBodyElement el = body.addBodyElement(ns); SOAPElement message; for(int i=0;i<Action_param.length;i++){ message = el.addChildElement(Action_param[i][0]); message.addTextNode(Action_param[i][1]); } // SOAPElement param = body.addChildElement("AnalysisRequest", "cal","http://calcul/"); // // SOAPElement idrequestnode = param.addChildElement("idRequest", "cal","http://calcul/"); request.saveChanges(); /** Invoke the service endpoint. **/ SOAPMessage response = dispatch.invoke(request); String idrequest = response.getSOAPPart().getEnvelope().getBody().getFirstChild().getTextContent(); System.out.println("Response: "+idrequest); return idrequest; } catch (Exception ex) { ex.printStackTrace(); } return ""; }
Maven me met cette erreur bizarre en m'indiquant que c'est la fonction précédemment montrée qui coince :
Voilà,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 D:\Projets\Application\Servlet_Portail_Portlet_Service\Debut_Portail>mvn package [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building [INFO] task-segment: [package] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [compiler:compile] [INFO] Compiling 6 source files to D:\Projets\Application\Servlet_Portail_Portle t_Service\Debut_Portail\target\classes [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure D:\Projets\Application\Servlet_Portail_Portlet_Service\Debut_Portail\src\main\ja va\org\jboss\portal\portlet\services\PortletConsommateur.java:[40,10] generics a re not supported in -source 1.3 (use -source 5 or higher to enable generics) Dispatch<SOAPMessage> dispatch = service.createDispatch(portName , D:\Projets\Application\Servlet_Portail_Portlet_Service\Debut_Portail\src\main\ja va\org\jboss\portal\portlet\services\PortletConsommateur.java:[40,10] generics a re not supported in -source 1.3 (use -source 5 or higher to enable generics) Dispatch<SOAPMessage> dispatch = service.createDispatch(portName , [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3 seconds [INFO] Finished at: Mon Nov 16 16:45:56 CET 2009 [INFO] Final Memory: 7M/13M [INFO] ------------------------------------------------------------------------
Je suis ouvert à toute demande de détail et question; et évidemment réponse ^^
Merci d'avance.
Mageni
Partager