Objet : Pour les administrateurs de serveurs de listes utilisant le logiciel Sympa
Archives de la liste
Re: [sympa-fr] Soap Java authenticateAndRun (Mapping Exception)
- From: Lionel Gadille <adresse@cachée>
- To: adresse@cachée
- Subject: Re: [sympa-fr] Soap Java authenticateAndRun (Mapping Exception)
- Date: Wed, 16 Oct 2013 10:25:52 +0200
On 15/10/2013 14:09, Lionel Gadille wrote:
Bonjour,
Je cherche a utiliser le service authenticateAndRun avec java et axis
SympaSOAP ss= new SympaSOAPLocator();
SympaPort_PortType port = ss.getSympaPort();
String result=port.login("adresse@cachée", "xxxx"); //OK
logger.debug(result); //ok
String[] arrayResult=port.authenticateAndRun("adresse@cachée", result, "info", new String []{"app2a_2013"}); //exception
Mapping Exception to AxisFault
java.lang.ArrayStoreException: java.lang.Boolean
La requette passe parfaitement sur soapui
Je supose que le probléme va être simple pour qu'elle qu'un ayant déjà utilisé le service
merci, Lionel
............................................................ toutes l'exception ........................................................
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.ArrayStoreException: java.lang.Boolean
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.lang.ArrayStoreException: java.lang.Boolean
at org.apache.axis.utils.JavaUtils.convert(JavaUtils.java:493)
at org.apache.axis.client.Call.invoke(Call.java:2599)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at ensimag.fr.SOAPStub.authenticateAndRun(SOAPStub.java:847)
at SympaSoapRemplissageList.delta(SympaSoapRemplissageList.java:37)
at SympaSoapRemplissageList.main(SympaSoapRemplissageList.java:24)
{http://xml.apache.org/axis/}hostname:ensinfo5.imag.fr
java.lang.ArrayStoreException: java.lang.Boolean
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.Call.invoke(Call.java:1828)
at ensimag.fr.SOAPStub.authenticateAndRun(SOAPStub.java:847)
at SympaSoapRemplissageList.delta(SympaSoapRemplissageList.java:37)
at SympaSoapRemplissageList.main(SympaSoapRemplissageList.java:24)
Caused by: java.lang.ArrayStoreException: java.lang.Boolean
at org.apache.axis.utils.JavaUtils.convert(JavaUtils.java:493)
at org.apache.axis.client.Call.invoke(Call.java:2599)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
... 3 more
Comme je n'est pas le temps de chercher une solution élégante je suis passé par du bas niveau
Si j'ai du temps à perdre j'essayerais de trouver pourquoi les stub ne fonctionne pas
cf le code pour demander de l'info sur une liste en passant par du bas niveaux (sans compilaltion du wsdl et génération des stub)
import javax.xml.soap.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import org.apache.log4j.Logger;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
// http://stackoverflow.com/questions/15948927/working-soap-client-example
public class SympaSoapXMlRemplissageList {
static final String url = "http://ensiml.imag.fr/sympasoap";
SOAPConnectionFactory soapConnectionFactory;
SOAPConnection soapConnection;
public static void main(String args[]) throws Exception {
SympaSoapXMlRemplissageList sm = new SympaSoapXMlRemplissageList();
sm.delta();
}
public void delta() throws Exception {
Logger logger = Logger.getLogger(new Exception().getStackTrace()[0].getClassName());
soapConnectionFactory = SOAPConnectionFactory.newInstance();
soapConnection = soapConnectionFactory.createConnection();
String code=getLogin();//recupe par soap du cokkies de login
logger.debug("info");
SOAPMessage soapResponse = soapConnection.call(requestInfo(code), url);
printSOAPResponse(soapResponse);
soapConnection.close();
}
/**
*
* @param code
* @return
* @throws Exception
*/
private static SOAPMessage requestInfo(String code) throws Exception {
Logger logger = Logger.getLogger(new Exception().getStackTrace()[0].getClassName());
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "urn:sympasoap";
// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance");
envelope.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema");
envelope.addNamespaceDeclaration("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
envelope.addNamespaceDeclaration("urn", "urn:sympasoap");
envelope.addNamespaceDeclaration("soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
envelope.addNamespaceDeclaration("urn", serverURI);
SOAPBody soapBody = envelope.getBody();
SOAPElement soapBodyElem = soapBody.addChildElement("authenticateAndRun", "urn");
SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email");
soapBodyElem1.addTextNode("adresse@cachée");
SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("cookie");
soapBodyElem2.addTextNode(code);
SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("service");
soapBodyElem3.addTextNode("info");
SOAPElement sEP = soapBodyElem.addChildElement("parameters");
Name name = envelope.createName("xsi:type");
sEP.addAttribute(name, "wsdl:ArrayOfString");
name = envelope.createName("soapenc:arrayType");
sEP.addAttribute(name, "xsd:string[]");
name = envelope.createName("xmlns:wsdl");
sEP.addAttribute(name, "http://ensiml.imag.fr/wws/wsdl");
SOAPElement sbeChil1 = sEP.addChildElement("item");
sbeChil1.addTextNode("app2a_2013");
soapMessage.saveChanges();
/* Print the request message */
logger.debug("Request SOAP Message = ");
if (logger.isDebugEnabled()) {
soapMessage.writeTo(System.out);
System.out.println();
}
return soapMessage;
}
/**
* Passe la requette de login
* @return
* @throws Exception
*/
private static SOAPMessage requestLogin() throws Exception {
Logger logger = Logger.getLogger(new Exception().getStackTrace()[0].getClassName());
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "urn:sympasoap";
// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("urn", serverURI);
SOAPBody soapBody = envelope.getBody();
SOAPElement soapBodyElem = soapBody.addChildElement("login", "urn");
SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email");
soapBodyElem1.addTextNode("adresse@cachée");
SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("password");
soapBodyElem2.addTextNode("xxxx");
// MimeHeaders headers = soapMessage.getMimeHeaders();
// headers.addHeader("SOAPAction", serverURI + "VerifyEmail");
soapMessage.saveChanges();
/* Print the request message */
logger.debug("Request SOAP Message = ");
if (logger.isDebugEnabled()) {
soapMessage.writeTo(System.out);
System.out.println();
}
return soapMessage;
}
/**
* Renvoie le code du login
* @return
* @throws SOAPException
* @throws Exception
*/
public String getLogin() throws SOAPException, Exception{
Logger logger = Logger.getLogger(new Exception().getStackTrace()[0].getClassName());
SOAPMessage soapResponse = soapConnection.call(requestLogin(), url);
//printSOAPResponse(soapResponse);
SOAPBody sb = soapResponse.getSOAPBody();
String code = null;
NodeList nl = sb.getElementsByTagName("result");
for (int i = 0; i < nl.getLength(); i++) {
Element e = (Element) nl.item(i);
code = e.getTextContent();
logger.debug("code:" + code);
}
return code;
}
/**
* Method used to print the SOAP Response
*/
private static void printSOAPResponse(SOAPMessage soapResponse) throws Exception {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = soapResponse.getSOAPPart().getContent();
Logger logger = Logger.getLogger(new Exception().getStackTrace()[0].getClassName());
if (logger.isDebugEnabled()) {
logger.debug("\nResponse SOAP Message = ");
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
System.out.print("\n");
}
}
}
--
Lionel Gadille, Ingénieur Service Informatique
Grenoble INP - Ensimag, bureau E208
681 rue de la Passerelle
BP 72, 38402 Saint Martin d'Hères CEDEX
Tél.: +33 (0)4 76 82 72 47
-
[sympa-fr] Soap Java authenticateAndRun (Mapping Exception),
Lionel Gadille, 15/10/2013
- Re: [sympa-fr] Soap Java authenticateAndRun (Mapping Exception), Lionel Gadille, 16/10/2013
Archives gérées par MHonArc 2.6.19+.