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
Secondo voi guardando il wsdl la classe Qname è settata bene? (QName qname = new QName("="http://XXXXXXXX:8080/sc_sms_ws/Sms", "Sms"));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")); } }