Envoie requete SOAP, Access denied
bonjour,
il m'arrive qq chose de bizarre, j'ai crée une appli d'envoi d'enveloppe soap par le httpclient jakarta. avec un analyseur HTTP, je me suis rendu compte que l'envoi se deroule en 2 requete...?!
la premiere requete est envoyée sans authentification (alors que je crée les credentials) et recoit un access denied, la requete est renvoyée automtiquement (je ne fais pourtant qu'un seul appel a HttpClient.executeMethod) avec cette fois l'authentification présente dans le flux HTTP avec en retour un acquittement ok
qq'un a une explication ? j'ai fait une bourde ?
voici le code :
url = new String("http://localhost:8081/soap/putMessage");
userName = "SoapClient";
password = "********";
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(url);
RequestEntity entity =null;
// http version, credentials
client.getParams().setVersion(HttpVersion.HTTP_1_0);
client.getState().setCredentials(AuthScope.ANY,new UsernamePasswordCredentials(userName,password));
try {
//flux = string de l'enveloppe SOAP
entity = new StringRequestEntity(flux, "text/xml","UTF-8");
method.setRequestEntity(entity);
int statusCode = client.executeMethod(method);
s_logger.info("statusCode : " + statusCode);
if (statusCode != HttpStatus.SC_OK) {
s_logger.error("Echec de la methode: " + method.getStatusLine());
}
String responseBody = method.getResponseBodyAsString();
} finally {
method.releaseConnection();
}
et le premier envoi HTTP :
POST /soap/putMessage HTTP/1.0
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8081
Content-Length: 640
Content-Type: text/xml; charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>*****</soapenv:Body></soapenv:Envelope>
la premiere reponse :
HTTP/1.0 401 [ISS.0084.9004] Access Denied
Set-Cookie: ssnid=6785ynwyYPAV1+EGllZd4aigwOVmFKI-556170; path=/;
Content-Type: text/html; charset=UTF-8
WWW-Authenticate: Basic realm="webMethods"
Connection: Close
Content-Length: 24
<h4>Access Denied</h4>
le deuxieme envoi :
POST /soap/putMessage HTTP/1.0
User-Agent: Jakarta Commons-HttpClient/3.1
Content-Length: 640
Content-Type: text/xml; charset=UTF-8
Authorization: Basic U29hcENsaWVudDpFZ3BTb2FwMDE=
Host:localhost:8081
Cookie: $Version=0; ssnid=6785ynwyYPAV1+EGllZd4aigwOVmFKI-556170; $Path=/
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>******</soapenv:Body></soapenv:Envelope>
la deuxieme reponse :
HTTP/1.0 200 OK
Content-Type: text/xml;charset=utf-8
Connection: Close
Content-Length: 445
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>********
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>