Visualizzazione dei risultati da 1 a 4 su 4

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2010
    Messaggi
    457

    Implementare un client per un Web Service

    Buongiorno a tutti,
    come da titolo avrei bisogno di implementare un client che vada a richiare un metodo di un webservice.
    Di seguito vi posto il wsdl e il relativo client che ho pensato di implementare.

    Sms.wsdl
    codice:
    <?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3-hudson-390-. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3-hudson-390-. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/...tility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://sc_sms_ws.aliaslab.net/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://sc_sms_ws.aliaslab.net/" name="Sms">
    <types>
    <xsd:schema>
    <xsd:import namespace="http://sc_sms_ws.aliaslab.net/" schemaLocation="Sms.xsd"></xsd:import>
    </xsd:schema>
    </types>
    <message name="SendPlus">
    <part name="parameters" element="tns:SendPlus"></part>
    </message>
    <message name="SendPlusResponse">
    <part name="parameters" element="tns:SendPlusResponse"></part>
    </message>
    <operation name="SendPlus">
    <input message="tns:SendPlus"></input>
    <output message="tns:SendPlusResponse"></output>
    </operation>
    </portType>
    <binding name="Sms2Binding" type="tns:SmsDelegate">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
    <operation name="SendPlus">
    <soap:operation soapAction=""></soap:operation>
    <input>
    <soap:body use="literal"></soap:body>
    </input>
    <output>
    <soap:body use="literal"></soap:body>
    </output>
    </operation>
    </binding>
    <service name="Sms">
    <port name="Sms2" binding="tns:Sms2Binding">
    <soap:address location="http://XXXXXXXX:8080/sc_sms_ws/Sms"></soap:address>
    </port>
    </service>
    </definitions>


    Questa di seguito è la classe client che dovrebbe collegarsi al web service
    codice:
    package com.mkyong.client;
     
    import java.net.URL;
    import javax.xml.namespace.QName;
    import javax.xml.ws.Service;
    import com.mkyong.ws.HelloWorld;
     
    public class HelloWorldClient{
     
    	public static void main(String[] args) throws Exception {
     
    	URL url = new URL("http://localhost:9999/ws/sms?wsdl");
     
            //1st argument service URI, refer to wsdl document above
    	//2nd argument is service name, refer to wsdl document above
            QName qname = new QName("="http://XXXXXXXX:8080/sc_sms_ws/Sms", "Sms");
     
            Service service = Service.create(url, qname);
     
            Smshello = service.getPort(Sms.class);
     
            System.out.println(Sms.inviaSms("mkyong"));
     
        }
     
    }
    Secondo voi guardando il wsdl la classe Qname è settata bene? (QName qname = new QName("="http://XXXXXXXX:8080/sc_sms_ws/Sms", "Sms"));

  2. #2
    dove è pubblicato questo webservice?
    sulla tua macchina?
    I computer sono incredibilmente veloci, accurati e stupidi.
    Gli uomini sono incredibilmente lenti, inaccurati e intelligenti.
    Insieme sono una potenza che supera l'immaginazione.

    A.Einstein

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2010
    Messaggi
    457
    Ciao Schumy2000, il web service non è pubblicato sulla mia macchina, si trova in remoto. Ma al momento lo sto testando con un mockup di SoapUi...ho creato la mia classe client:
    codice:
    package it.sia.webinterface.ws.sms;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class TestSMS {
     public static void main(String[] args) throws MalformedURLException {
      
       URL  url= new URL("http://p02150624:8088/mockSms2Binding?wsdl");  
      
          Sms serviceSms=new Sms(url);
          
          SmsDelegate smsDelegate=serviceSms.getSms2();
          
          int risposta=smsDelegate.sendPlus("user", "PSW", "Multa da pagare", "3388264202", "0", true, 0, 1, null, "Peppa Luongo", "NON");
          
          System.out.println("RetCode = "+risposta);
          
          
     }
    }
    Ho lanciato questa classe client, ma ottengo la seguente eccezione:
    codice:
    6-mar-2015 9.03.55 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
    INFO: Dynamically creating request wrapper Class net.aliaslab.sc_sms_ws.SendLongConcatenatoWithRcpt
    26-mar-2015 9.03.55 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
    INFO: Dynamically creating response wrapper bean Class net.aliaslab.sc_sms_ws.SendLongConcatenatoWithRcptResponse
    26-mar-2015 9.03.55 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
    INFO: Dynamically creating request wrapper Class net.aliaslab.sc_sms_ws.SendLongConcatenato
    26-mar-2015 9.03.55 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
    INFO: Dynamically creating response wrapper bean Class net.aliaslab.sc_sms_ws.SendLongConcatenatoResponse
    Exception in thread "main" javax.xml.ws.WebServiceException: Unable to create JAXBContext
     at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
     at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83)
     at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244)
     at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:687)
     at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:675)
     at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:330)
     at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:313)
     at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:295)
     at javax.xml.ws.Service.getPort(Service.java:92)
     at it.sia.webinterface.ws.sms.Sms.getSms2(Sms.java:55)
     at it.sia.webinterface.ws.sms.TestSMS.main(TestSMS.java:15)
    Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 28 counts of IllegalAnnotationExceptions
    Two classes have the same XML type name "{http://sc_sms_ws.aliaslab.net/}SMSStatus". Use @XmlType.name and @XmlType.namespace to assign different names to them.
     this problem is related to the following location:
      at it.sia.webinterface.ws.sms.SMSStatus
    Qualcuno ha idea di cosa si potrebbe trattare?

  4. #4
    te lo dice:

    codice:
    Two classes have the same XML type name "{http://sc_sms_ws.aliaslab.net/}SMSStatus". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    controlla che il wsdl sia corretto. Ma soapui lo carica correttamente?
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.