Mapping qname not fond for the package: org.apache.axis2.saaj
Hi!
Je suis entrain de faire Service Web JAX-WS. le service doit retourner un fichier au format .ZIP. J'utilise donc l'API SAAJ.
Voici les paramètres de mon environnement:
Ubuntu 8.10 (Linux Kernel: 2.6.27-11-generic), jdk1.6.0_10, axis2-1.4.1, apache-tomcat-6.0.16
J'ai déployé le service en utilisant Eclipse Plugin Axis2 Code Service Archiver, et j'ai mis l'archive du service (.aar) dans le repository d'axis2 dans /CATALINA_HOME/webapps/axis2/WEB-INF/services
VOICI LE CODE DU SERVICE
Code:
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| /**
*
*/
package dialogue;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javax.activation.DataHandler;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.swing.JOptionPane;
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
/**
* @author root
* @since Mercredi 06 Mai 2009 11:27
* @version 1.0
*/
@WebService
public class FileService {
private String fileName = null;
private MessageFactory messageFactory = null;
private SOAPMessage message = null;
private SOAPPart part = null;
private SOAPEnvelope envelope = null;
private SOAPHeader header = null;
private SOAPBody body = null;
private QName name = null;
private SOAPBodyElement soapBodyElement = null;
private QName nameContenu = null;
private SOAPElement soapElement = null;
private AttachmentPart attachmentPart = null;
private Collection<String> collection = null;
public FileService() {
}
/**
* @param filesToGet
* @return
*/
@WebMethod
public SOAPMessage recupererFile(@WebParam(name="filesToGet") String fileToGet){
dialFiles = new DialFiles();
dialFiles.setFileToGet(fileToGet);
try {
fileName = dialFiles.returnRequestedFileName();
} catch (Exception e1) {
e1.printStackTrace();
//send SOAPFault
}
try {
messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
message = messageFactory.createMessage();
part = message.getSOAPPart();
envelope = part.getEnvelope();
header = envelope.getHeader();
header.detachNode();
body = envelope.getBody();
name = new QName("http://dialogue","Remerciement", "rm");
soapBodyElement = body.addBodyElement(name);
nameContenu = new QName("libellé");
soapElement = soapBodyElement.addChildElement(nameContenu);
soapElement.addTextNode("Merci de la copie!");
URL url = new URL("file:////temp/"+fileName);
DataHandler dataHandler = new DataHandler(url);
attachmentPart = message.createAttachmentPart(dataHandler);
attachmentPart.setContentId("attached_file");
message.addAttachmentPart(attachmentPart);
} catch (SOAPException e) {
e.printStackTrace();
//send SOAPFault
}catch (MalformedURLException e) {
e.printStackTrace();
//send SOAPFault
}
return message;
}
} |
VOICI LE CODE DU CLIENT:
Code:
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
| package client;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
/**
* @author root
* @since Vendredi 08 Mai 2009 23:08
* @version 1.0
*/
public class ClasseCliente {
private SOAPConnectionFactory soapConnectionFactory = null;
private SOAPConnection soapConnection = null;
private MessageFactory messageFactory = null;
private SOAPMessage soapMessage = null;
private SOAPHeader soapHeader = null;
private SOAPBody soapBody = null;
private QName bodyName = null;
private SOAPBodyElement soapBodyElement = null;
private QName name = null;
private SOAPElement soapElement = null;
private URL endpointUrl = null;
private SOAPMessage reponse = null;
private AttachmentPart attachmentPartReponse = null;
private SOAPBody soapBodyreponse = null;
private Iterator<SOAPBodyElement> iterator = null;
private SOAPBodyElement soapBodyElementReponse = null;
private String contenuReponse = null;
private Iterator<AttachmentPart> iterator2 = null;
public void recupererFile(){
try {
soapConnectionFactory = SOAPConnectionFactory.newInstance();
soapConnection = soapConnectionFactory.createConnection();
messageFactory = MessageFactory.newInstance();
soapMessage = messageFactory.createMessage();
soapHeader = soapMessage.getSOAPHeader();
soapHeader.detachNode();
soapBody = soapMessage.getSOAPBody();
bodyName = new QName("http://dialogue", "recupererFile", "rm");
soapBodyElement = soapBody.addBodyElement(bodyName);
name = new QName("FileName");
soapElement = soapBodyElement.addChildElement(name);
soapElement.addTextNode("MyFile-1.1");
try {
endpointUrl = new URL("http://localhost:8080/axis2/services/ServiceEntrepotService");
} catch (MalformedURLException e) {
e.printStackTrace();
}
soapMessage = soapConnection.call(soapMessage, endpointUrl);
soapConnection.close();
soapBody = soapMessage.getSOAPBody();
if(soapBody.hasFault()){
System.out.println("There's a fault!");
SOAPFault faute = soapBody.getFault();
QName code = faute.getFaultCodeAsQName();
String stringFaute = faute.getFaultString();
String actor = faute.getFaultActor();
System.out.println("Fault content:");
System.out.println("Code: "+code.toString());
System.out.println("Local name: "+code.getLocalPart());
System.out.println("Namespace Prefix= "+code.getPrefix()+", bound to "+code.getNamespaceURI());
System.out.println("Fault String: "+stringFaute);
if(actor!=null){
System.out.println("Actor: "+actor);
}
}
iterator = soapBody.getChildElements();
while(iterator.hasNext()){
System.out.println("Message:");
soapBodyElement = iterator.next();
System.out.println(soapBodyElement.getNodeName());
contenuReponse = soapBodyElement.getValue();
System.out.println("The message is: "+contenuReponse);
}
iterator2 = soapMessage.getAttachments();
while(iterator2.hasNext()){
attachmentPartReponse = iterator2.next();
String id = attachmentPartReponse.getContentId();
System.out.println("Attachment's Content ID: "+id);
String type = attachmentPartReponse.getContentType();
System.out.println("Attachment's Content Type: "+type);
InputStream theFileRequested = (InputStream)attachmentPartReponse.getContent();
Integer nb =null;
try {
nb = theFileRequested.available();
} catch (IOException e1) {
e1.printStackTrace();
}
byte[] b = null ;
try {
FileOutputStream fileOutputStream = new FileOutputStream("/root");
fileOutputStream.write(theFileRequested.read(b, 0, nb));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (UnsupportedOperationException e) {
e.printStackTrace();
} catch (SOAPException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
ClasseCliente classeCliente = new ClasseCliente();
classeCliente.recupererFile();
}
} |
Quand j'exécute le client, j'ai cette exception:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| javax.xml.soap.SOAPException: org.apache.axis2.AxisFault: Mapping qname not fond for the package: org.apache.axis2.saaj
at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:194)
at org.apache.axis2.saaj.SOAPConnectionImpl.call(SOAPConnectionImpl.java:130)
at client.ClasseCliente.recupererFile(ClasseCliente.java:77)
at client.ClasseCliente.main(ClasseCliente.java:145)
Caused by: org.apache.axis2.AxisFault: org.apache.axis2.AxisFault: Mapping qname not fond for the package: org.apache.axis2.saaj
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:188)
... 3 more |
de quel qname s'agit-il? Comment corriger ce probleme?