SoapHeader : s'authentifier proprement a un WebService SOAP



Similar documents
Middleware and the Internet

Middleware and the Internet. Example: Shopping Service. What could be possible? Service Oriented Architecture

JAVA API FOR XML WEB SERVICES INTRODUCTION TO JAX-WS, THE JAVA API FOR XML BASED WEB SERVICES (SOAP, WSDL)

NetBeans IDE Field Guide

Personnalisez votre intérieur avec les revêtements imprimés ALYOS design

Web-Service Example. Service Oriented Architecture

Developing Java Web Services

Licence Informatique Année Exceptions

Les Broadcast Receivers...

PRMS.

WEB SERVICES. Revised 9/29/2015

Web Service Development Using CXF. - Praveen Kumar Jayaram

Remote Method Invocation

ITS. Java WebService. ITS Data-Solutions Pvt Ltd BENEFITS OF ATTENDANCE:

Using ilove SharePoint Web Services Workflow Action

Freight Tracking Web Service Implementation Guide

Java Web Services Training

Note concernant votre accord de souscription au service «Trusted Certificate Service» (TCS)

TP1 : Correction. Rappels : Stream, Thread et Socket TCP

Developing Web Services Applications

ESMA REGISTERS OJ/26/06/2012-PROC/2012/004. Questions/ Answers

JVA-561. Developing SOAP Web Services in Java

Méthodes ensemblistes pour une localisation robuste de robots sous-marins

Technical Service Bulletin

Liste d'adresses URL

HEALTH CARE DIRECTIVES ACT

Proposition d intervention

ExempleRMI.java. // Fichier de defintion des droits et proprietes // System.setProperty("java.security.policy","../server.java.

GetFormatList. Webservice name: GetFormatList. Adress:

Perceptive Connector for Infor Lawson AP Invoice Automation

Group Projects M1 - Cubbyhole

Brazil + JDBC Juin 2001, douin@cnam.fr

Microsoft Active Directory Oracle Enterprise Gateway Integration Guide

AgroMarketDay. Research Application Summary pp: Abstract

Introduction au BIM. ESEB Seyssinet-Pariset Economie de la construction contact@eseb.fr

A web-based multilingual help desk

JAX-WS Developer's Guide

First-half 2012 Results. August 29 th, Jean-Paul AGON. Chairman and CEO

The BritNed Explicit Auction Management System. Kingdom Web Services Interfaces

Future Entreprise. Jean-Dominique Meunier NEM Executive Director Nov. 23, 2009 FIA Stockholm

Configuration Guide. SafeNet Authentication Service. SAS Agent for AD FS

Modifier le texte d'un élément d'un feuillet, en le spécifiant par son numéro d'index:

Survey on Conference Services provided by the United Nations Office at Geneva

Sun Management Center Change Manager Release Notes

Langages Orientés Objet Java

General Certificate of Education Advanced Level Examination June 2012

Managed Rebill web services

XML in Programming 2, Web services

POB-JAVA Documentation

Sage CRM. Sage CRM 2016 R1 Web Services Guide

Les fragments. Programmation Mobile Android Master CCI. Une application avec deux fragments. Premier layout : le formulaire

Tanenbaum, Computer Networks (extraits) Adaptation par J.Bétréma. DNS The Domain Name System

TP : Système de messagerie - Fichiers properties - PrepareStatement

CERN EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH

Annexe - OAuth Introduction. Xavier de Rochefort xderoche@labri.fr - labri.fr/~xderoche 15 mai 2014

ATP Co C pyr y ight 2013 B l B ue C o C at S y S s y tems I nc. All R i R ghts R e R serve v d. 1

European Access Point for Truck Parking Data

Web Services. Distributed Object Systems 11. Web Services, SOAP and NET. Web Applications. Web Services. Web services vs Distributed Objects

Strategic Workforce Planning and Competency Management at Schneider Electric

Évariste Galois and Solvable Permutation Groups

ACP-EU Cooperation Programme in Science and Technology (S&T II) / Programme de Coopération ACP-UE pour la Science et la Technologie

Solaris 10 Documentation README

EPREUVE D EXPRESSION ORALE. SAVOIR et SAVOIR-FAIRE

Power Distribution System. Additional Information on page 2 See Page 2 Page 6. Eaton. See Page 2. Additional Information on page 2

Interfaces de programmation pour les composants de la solution LiveCycle ES (juillet 2008)

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

Bluetooth Low Energy

Elizabethtown Area School District French III

BILL C-665 PROJET DE LOI C-665 C-665 C-665 HOUSE OF COMMONS OF CANADA CHAMBRE DES COMMUNES DU CANADA

How to evaluate your communications actions

Tool & Asset Manager 2.0. User's guide 2015

Alberta Petroleum Marketing Commission

We are pleased to present you with detailed instructions on processing your visa application with us. Within this information pack you will find:

TREATIES AND OTHER INTERNATIONAL ACTS SERIES Agreement Between the UNITED STATES OF AMERICA and CONGO

Le(s) auteur(s) par la presente cede(nt) a. I'IFIP en toute exclusivite et dans tous les pays tous les droits relatifs a. l'oeuvre

Report to Rapport au: Council Conseil 9 December 2015 / 9 décembre Submitted on October 26, 2015 Soumis le 26 octobre 2015

Creating a Simple Business Collaboration Scenario With a BPMS

"Internationalization vs. Localization: The Translation of Videogame Advertising"

Voici votre rapport sur votre service OpenERP en ligne.

Access to. Information Request Form

Cours de Java. Sciences-U Lyon. Java - Introduction Java - Fondamentaux Java Avancé.

Séries U3-CMOS. Nouvelles. Caméras Numériques USB3. Ultra rapides

IMPROVING EFFICIENCY AND PRODUCTIVITY IN THE CONSTRUCTION SECTOR THROUGH THE USE OF INFORMATION TECHNOLOGIES

Archived Content. Contenu archivé

Percentage Ladder French Unit 1: Qu est-ce que tu aimes regarder? Year 8 Reading and Speaking

Calcul parallèle avec R

Creating Web Services in NetBeans

Ça marche! 3 Scope and Sequence

2 RENSEIGNEMENTS CONCERNANT L ASSURÉ SI CELUI-CI N EST PAS LE REQUÉRANT INFORMATION CONCERNING THE INSURED PERSON IF OTHER THAN THE APPLICANT

Transcription:

SoapHeader : s'authentifier proprement a un WebService SOAP Une s olution e st d'utiliser l'en - tete d'une requête SOAP. Pour cela on va tout d'abord créer u n nouveau type qui hérite de SoapHeader, ce type contiendra les infor mations de connexion : public class CredentialHeader : SoapHeader public CredentialHeader() : base() public CredentialHeader(int Pid) : base() this._pid = Pid; private int _Pid; public int Pid get return _Pid; set _Pid = value; Ensuite nous rajoutons l'attribute SoapHeaderAttribute sur la WebMethod qui prend en argu ment le no m d'une variable p ublic d u type que l'on vient de créer. Ainsi lorsqu'un client enverra u ne requête SOAP contenant les infor mations de connexion dans l'en - tête, notre variable A uthentication sera auto matique ment renseigné, nous po uvons alors tester si le pid pour le suivit de notre correlation. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService public CredentialHeader Authentication; [WebMethod] [SoapHeader("Authentication")] public Product GetProduct(int productid) if (Authentication.Pid == 5) return new Product(productID, "title", "description", 100); else throw new System.Security.Authentication.InvalidCredentialException();

Notre requête SOAP devra donc contenir les infor mations de connexions da ns le header. Cela se traduit par u ne requête de ce type : <?xml version="1.0" encoding="utf 8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:header> <CredentialHeader xmlns="http://tem puri.org/"> <Pid>int</Pid> </CredentialHeader> </soap:header> <soap:body> <GetProduct xmlns="http://tempuri.org/"> <productid>int</productid> </GetProduct> </soap:body> </soap:envelope> Pour envoyer les para métres dans le header d'un requete SOAP nous référençons classique ment notre p ara métre en faisant u n "Add Web Reference" dans Visual Studio. Puis lorsque nous instancions notre classe proxy, nous avons la possibilité de renseigner u ne pro priété CredentialHeaderValue de type CredentialHeader : WS.WebService ws = new WS.WebService(); ws.credentialheadervalue = new WS.CredentialHeader(); ws.credentialheadervalue.pid = 5; Console.WriteLine(ws.GetProduct(10).Price); SOAP with Attachments API for Java SOAP API for Java (SAAJ) is used m ainly for the SOAP m essaging that goes on behind the scenes in JAX-RPC and JAXR implementations. Secondarily, it is an API that developers can use when they choose to write SOAP messaging applications directly rather than use JAX-RPC. The SAAJ API allows you to do XML messaging fro m the Java platfor m: By simply m aking method calls using the SAAJ API, you can read an d write SOAP - based XML messages, an d you can optionally send an d receive such messages over the Internet (some implementations m ay not s u p port sending an d receiving). This chapter will help you learn how to use the SAAJ API. The SAAJ API confor ms to the Simple Object Access Protocol (SOAP) 1.1 s pecification an d the SOAP with Attach ments s pecification. The SAAJ 1.2 s pecification defines the javax.xml.soap package, which contains the API for creating and populating a SOAP message. This package has all the API necessary for sen ding request - res ponse messages. (Request - response m essages are explained in SOAPConnection Objects.) Le processu s fonctionne en 5 étpes:

1. creation d'un connection SOAP 2. Creation d'un message SOAP 3. le re m plir 4. l'e nvoyer 5. Recevoir la reponse I/ Connection import javax.xml.soap.soapconnectionfactory; import javax.xml.soap.soapconnection; public class SOAPTip try //First create the connection SOAPConnectionFactory soapconnfactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapconnfactory.createconnection(); catch(exception e) System.out.println(e.getMessage()); II/creation du mes sage import javax.xml.soap.soapconnectionfactory; import javax.xml.soap.soapconnection; import javax.xml.soap.messagefactory; import javax.xml.soap.soapmessage; import javax.xml.soap.soappart; import javax.xml.soap.soapenvelope; import javax.xml.soap.soapbody; public class SOAPTip try //First create the connection SOAPConnectionFactory soapconnfactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapconnfactory.createconnection(); //Next, create the actual message

MessageFactory messagefactory = MessageFactory.newInstance(); SOAPMessage message = messagefactory.createmessage(); //Create objects for the message parts SOAPPart soappart = message.getsoappart(); SOAPEnvelope envelope = soappart.getenvelope(); SOAPBody body = envelope.getbody(); catch(exception e) System.out.println(e.getMessage()); III/ Remplissage du message import javax.xml.soap.soapbody; import javax.xml.soap.soapelement; public class SOAPTip try //Create objects for the message parts SOAPPart soappart = message.getsoappart(); SOAPEnvelope envelope = soappart.getenvelope(); SOAPBody body = envelope.getbody(); //Populate the body //Create the main element and namespace SOAPElement bodyelement = body.addchildelement(envelope.createname("getprice", "ns1", "urn:xmethods BNPriceCheck")); //Add content bodyelement.addchildelement("isbn").addtextnode("0672324229"); //Save the message message.savechanges(); //Check the input System.out.println("\nREQUEST:\n"); message.writeto(system.out); System.out.println(); catch(exception e) System.out.println(e.getMessage());

IV /Envois du message public class SOAPTip //Check the input System.out.println("\nREQUEST:\n"); message.writeto(system.out); System.out.println(); //Send the message and get a reply //Set the destination String destination = "http://services.xmethods.net:80/soap/servlet/rpcrouter"; //Send the message SOAPMessage reply = connection.call(message, destination); V / Reception de la reponse import javax.xml.transform.transformerfactory; import javax.xml.transform.transformer; import javax.xml.transform.source; import javax.xml.transform.stream.streamresult; public class SOAPTip try //Send the message SOAPMessage reply = connection.call(message, destination); //Check the output System.out.println("\nRESPONSE:\n"); //Create the transformer TransformerFactory transformerfactory = TransformerFactory.newInstance(); Transformer transformer = transformerfactory.newtransformer();

//Extract the content of the reply Source sourcecontent = reply.getsoappart().getcontent(); //Set the output for the transformation StreamResult result = new StreamResult(System.out); transformer.transform(sourcecontent, result); System.out.println();