Foros del Web » Programación para mayores de 30 ;) » Java »

WebService en php y cliente java

Estas en el tema de WebService en php y cliente java en el foro de Java en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 18/04/2011, 06:42
 
Fecha de Ingreso: abril-2011
Mensajes: 1
Antigüedad: 13 años
Puntos: 0
WebService en php y cliente java

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!!!!!!

Etiquetas: cliente, php, webservice
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:07.