Thread View: es.comp.lenguajes.java
1 messages
1 total messages
Started by Leto Atreides
Thu, 06 Sep 2007 12:37
Problemas con acceso dinámico a un Web Service
Author: Leto Atreides
Date: Thu, 06 Sep 2007 12:37
Date: Thu, 06 Sep 2007 12:37
118 lines
5365 bytes
5365 bytes
Hola a todos:
Tengo el siguiente Web Service de prueba:
@WebService()
public class TestWebService {
@WebMethod
public String sayHello(@WebParam(name = "name") String name) {
return "Hello " + name + "!";
}
}
Y tengo un cliente generado con el NetBeans que accede correctamente a
�l. Ahora bien, el problema es que si cambio el Web Service de servidor
tengo que volver a compilar mi aplicaci�n asoci�ndolo al nuevo servidor.
Para evitar esto, he visto por internet el siguiente c�digo:
String wsdlURL =
"http://localhost:8084/TestWebApplication/TestWebService?wsdl";
String serviceName = "TestWebServiceService";
String portName = "TestWebServicePort";
String operationName = "sayHello";
try {
// create the Service client object using the wsdl and his service name
QName serviceQName = new QName(wsdlURL, serviceName);
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(serviceQName);
// Call object
QName portQName = new QName(wsdlURL, portName);
QName operationQName = new QName(wsdlURL, operationName);
Call call = service.createCall(portQName,operationQName);
// input parameter
call.addParameter("name", serviceQName,ParameterMode.IN);
// setting return type
call.setReturnType(XMLType.XSD_STRING);
// specify the RPC-style operation.
call.setProperty(Call.OPERATION_STYLE_PROPERTY, "rpc");
// and the encoding style
call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
// the target endpoint
call.setTargetEndpointAddress(wsdlURL);
// Invoke the method readLSpercent
Object[] myArgs = {"Leto Atreides"};
Object lsVal = call.invoke(myArgs);
System.out.println("Result: " + lsVal.toString());
}
catch(Throwable th) {
th.printStackTrace();
}
Pero cuando ejecuto el cliente, en el servidor me aparece el siguiente
error:
Caused by: javax.xml.ws.soap.SOAPFaultException: Cannot find the
dispatch method at
com.sun.xml.ws.encoding.soap.SOAPDecoder.raiseFault(SOAPDecoder.java:674)
at
com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.decodeDispatchMethod(SOAPXMLDecoder.java:152)
at
com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBodyContent(SOAPDecoder.java:337)
at
com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBody(SOAPDecoder.java:327)
at
com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeEnvelope(SOAPDecoder.java:250)
at
com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.toInternalMessage(SOAPXMLDecoder.java:81)
Googleando por ah� he le�do que el problema est� en los namespaces pero
ni s� como solucionarlo, ni estoy seguro que sea eso.
Pego aqu� el wsdl a ver si alguna alma caritativa me puede ayudar:
<?xml version="1.0" encoding="UTF-8"?><definitions
xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://test/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://test/" name="TestWebServiceService">
<types>
<xsd:schema>
<xsd:import
schemaLocation="http://localhost:8084/TestWebApplication/TestWebService?xsd=1"
namespace="http://test/"></xsd:import>
</xsd:schema>
</types>
<message name="sayHello">
<part element="tns:sayHello" name="parameters"></part>
</message>
<message name="sayHelloResponse">
<part element="tns:sayHelloResponse" name="parameters"></part>
</message>
<portType name="TestWebService">
<operation name="sayHello">
<input message="tns:sayHello"></input>
<output message="tns:sayHelloResponse"></output>
</operation>
</portType>
<binding name="TestWebServicePortBinding" type="tns:TestWebService">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
<operation name="sayHello">
<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="TestWebServiceService">
<port name="TestWebServicePort" binding="tns:TestWebServicePortBinding">
<soap:address
location="http://localhost:8084/TestWebApplication/TestWebService"></soap:address>
</port>
</service>
</definitions>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads