Buenas!!
tengo un problemilla.
Me han montado un WS hecho en java y tengo que crear un cliente java para atarcalo.
El caso es que me he quedado en siguiente error tras estar leyendo varias formas de implementarlo:
Error de transporte HTTP: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:application/wsdl+xml. Is this an error message instead of a SOAP response?
Basicamente he hecho esto:
* J2SE unmanaged application
* Service lookup: JAX-RPC ServiceFactory
* Service access: DII
*/
package SoapClient;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
public class SoapClient {
public static void main(String[] args) {
String targetNamespace = "***********.wsdl";
try {
// create the Service client object
// using the wsdl and his service name
QName serviceName = new QName(
targetNamespace,****);
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(serviceName);
// Call object
Call call = service.createCall();
// operation name
call.removeAllParameters();
QName operationName = new QName("***", "metedo");
call.setOperationName(operationName);
// input parameter
call.addParameter(
"codigo", // parameter name
XMLType.XSD_STRING, // parameter XML type QName
String.class, // parameter Java type class
ParameterMode.IN); // parameter mode
// setting return type
call.setReturnType(XMLType.XSD_STRING);
// specify the RPC-style operation.
call.setProperty(Call.OPERATION_STYLE_PROPERTY,"rp c");
// and the encoding style
call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "http://schemas.xmlsoap.org/soap/encoding/");
// the target endpoint
call.setTargetEndpointAddress(targetNamespace);
// Invoke the method readLSpercent
Object[] myArgs = {new String("90")};
Object lsVal = call.invoke(myArgs);
//invocar sin parametros al método. Object lsVal = call.invoke( (Object[]) null );
System.out.println("Light sensor value: " + lsVal.toString());
}
catch (Exception e) {
System.err.println(e.toString());
}
}
}
Toda ayuda seria bienvenida :)
gracias!!!!!!