IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Java Discussion :

consommer des webservices : client standalone


Sujet :

Services Web Java

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Janvier 2008
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Janvier 2008
    Messages : 2
    Points : 1
    Points
    1
    Par défaut consommer des webservices : client standalone
    bonjour a tous

    dans le cadre d'un projet étudiant, je dois faire tourner un web service sur Jonas (4.8)

    j'ai reussi a deployer l'exemple de jonas (la webapp wswarsample) et jaimerais mnt tester ce ws avec un client java standalone

    j'ai lu le tuto de sun et celui d'ibm websphere et j'ai tenté le dynamic proxy

    voici mon code

    classe client

    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
     
    import java.net.URL;
    import javax.xml.rpc.Service;
    import javax.xml.rpc.ServiceFactory;
    import javax.xml.namespace.QName;
     
    public class HelloClientDP {
     
     public static void main(String args[]) {
            try {
                // Create a service class with WSDL information.
               QName serviceName = new QName("http://ws.servlets.wssample.objectweb.org","JaxRpcEndpointInterfaceService");
               URL wsdlLocation = new URL("http://localhost:9000/wswarsample/endpoints/jaxrpc?JWSDL");
               ServiceFactory factory = ServiceFactory.newInstance();
               Service service = factory.createService(wsdlLocation,serviceName);
     
     
         // Get an implementation for the SEI for the given port
                QName portName = new QName("http://ws.servlets.wssample.objectweb.org", "JaxRpcEndpoint1");
                JaxRpcEndpointInterface quote = (JaxRpcEndpointInterface) service.getPort(portName,JaxRpcEndpointInterface.class);
     
               // Invoke the operation
                  System.out.println(quote.sayHello("Buzz"));
            }
            catch (Throwable t) {
                t.printStackTrace();
            }
        }
    }
    la SEI :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    import java.rmi.Remote;
    import java.rmi.RemoteException;
     
    public interface JaxRpcEndpointInterface extends Remote {
     
        String sayHello(String name) throws RemoteException;
     
        int getCotes() throws RemoteException;
    }
    et le wsdl

    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
    <definitions name="" targetNamespace="http://ws.servlets.wssample.objectweb.org">
    <message name="getCotesRequest">
     
       </message>
    −
    	<message name="sayHelloRequest">
    <part name="in0" type="xsd:string"/>
    </message>
    −
    	<message name="sayHelloResponse">
    <part name="sayHelloReturn" type="xsd:string"/>
    </message>
    −
    	<message name="getCotesResponse">
    <part name="getCotesReturn" type="xsd:int"/>
    </message>
    −
    	<portType name="JaxRpcEndpointInterface">
    −
    	<operation name="sayHello" parameterOrder="in0">
    <input message="impl:sayHelloRequest" name="sayHelloRequest"/>
    <output message="impl:sayHelloResponse" name="sayHelloResponse"/>
    </operation>
    −
    	<operation name="getCotes">
    <input message="impl:getCotesRequest" name="getCotesRequest"/>
    <output message="impl:getCotesResponse" name="getCotesResponse"/>
    </operation>
    </portType>
    −
    	<binding name="JaxRpcEndpointSoapBinding" type="impl:JaxRpcEndpointInterface">
    <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    −
    	<operation name="sayHello">
    <wsdlsoap:operation soapAction="http://ws.servlets.wssample.objectweb.org/sayHello"/>
    −
    	<input name="sayHelloRequest">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/>
    </input>
    −
    	<output name="sayHelloResponse">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/>
    </output>
    </operation>
    −
    	<operation name="getCotes">
    <wsdlsoap:operation soapAction="http://ws.servlets.wssample.objectweb.org/getCotes"/>
    −
    	<input name="getCotesRequest">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/>
    </input>
    −
    	<output name="getCotesResponse">
    <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.servlets.wssample.objectweb.org" use="encoded"/>
    </output>
    </operation>
    </binding>
    −
    	<service name="JaxRpcEndpointInterfaceService">
    −
    	<port binding="impl:JaxRpcEndpointSoapBinding" name="JaxRpcEndpoint1">
    <wsdlsoap:address location="http://localhost:9000/wswarsample/endpoints/jaxrpc"/>
    </port>
    −
    	<port binding="impl:JaxRpcEndpointSoapBinding" name="EncryptedJaxRpcEndpoint">
    <wsdlsoap:address location="http://localhost:9000/wswarsample/endpoints/encrypted"/>
    </port>
    </service>
    </definitions>
    apres compilation et execution :

    Axisfault
    faultCode:{http://xml.apache.org/axis/}Server
    faultSubcode:
    faultString: Server Error

    ...

    une idée

  2. #2
    Nouveau Candidat au Club
    Inscrit en
    Janvier 2008
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Janvier 2008
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    apparemment, le probleme vient de l'authentification avec WSS4J ( a part ca, le cod efonctionne)

    comment attribuer les droits à mon client java ?

Discussions similaires

  1. Réponses: 2
    Dernier message: 07/04/2015, 13h25
  2. [WebServices] consommer des services web ?
    Par Nycos62 dans le forum Services Web
    Réponses: 3
    Dernier message: 12/04/2005, 13h13
  3. [XMLRAD] Security des WebModules et/ou des WebServices
    Par Lux interior dans le forum XMLRAD
    Réponses: 4
    Dernier message: 18/12/2002, 17h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo