Search code examples
javaweb-servicesweblogic12c

Submit a post xml request to webservice hosted on weblogic and get a response xml from client request


I am trying to send post requests to a webservice that is in weblogic. I am using soapui to make the requests, this tool structures me the object that I have to send to XML format, but when I send the request it gives me the error: org.apache.http.NoHttpResponseException: The target server failed to respond.

Any ideas ? The webservice I did, it is not that I am consulting any external.

JDNI connection:

if ( conn == null ){

        Context ctx = null;

        try{

            ctx = new InitialContext();

            DataSource ds = (DataSource) ctx.lookup("jdbc_oracle_ws");

            conn = ds.getConnection();

        }catch(Exception ex){}
}

Code webservice method

@WebService(serviceName = "ConsultarRecibosPendientes", targetNamespace = "http://websercice.fi.co/")
public class ConsultarRecibosPendientes extends Base {

        @WebMethod(operationName = "ConsultarRecibosPendientes")
        @WebResult(name = "ConsultarRecibosPendientesResult")
        public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(@WebParam(
                name = "ConsultarRecibosPendientesReq") ConsultarRecibosPendientesReq objeto) {

            ConsultarRecibosPendientesRes recibosRes = new ConsultarRecibosPendientesRes();

            cliente_servicio = ConsultarInformacionClienteServicio( objeto.nCodBanco,
                                                                        objeto.nCodAgencia,
                                                                        objeto.nCodInstitucion,
                                                                        objeto.nCodConvenio,
                                                                        objeto.nTipoBusqueda,
                                                                        objeto.nTipoLlaveAcceso,
                                                                        objeto.strLlaveAcceso);

            recibosRes.nCodRespuesta = cliente_servicio.codigoRespuesta;
            recibosRes.nTipoIdentificacion = cliente_servicio.tipoIdentificacion;
            recibosRes.strIdentificacion = cliente_servicio.identificacionCliente.replace("-", "").trim();
            recibosRes.strNombreCliente = cliente_servicio.nombreCliente;
            recibosRes.nFechaTransaccion = cliente_servicio.fechaTransaccion;
            recibosRes.nCantServicios = cliente_servicio.cantServicios;

            return recibosRes;

        }
    }

Solution

  • The connection to the database is fine, you just have to create a "data source" on the WebLogic server with the specifications we need, in my case a thin oracle instance connection.

    Then, as I defined certain properties of the XML in my code, the XML that generates automatic SOAP UI was not serving me, I had to create the XML following my specifications, so I could get communication with the WebService.

    The XML that served me was the following:

    <?xml version='1.0' encoding='UTF-8'?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
            <web:ConsultarRecibosPendientes xmlns:web="http://websercice.fi.co/">
                <oReq>
                    <nCodBanco>150</nCodBanco>
                    <nCodAgencia>1</nCodAgencia>
                    <nCodInstitucion>1</nCodInstitucion>
                    <nCodConvenio>1</nCodConvenio>
                    <nTipoBusqueda>1</nTipoBusqueda>
                    <nTipoLlaveAcceso>1</nTipoLlaveAcceso>
                    <strLlaveAcceso>llave de acceso</strLlaveAcceso>
                </oReq>
            </web:ConsultarRecibosPendientes>
        </soap:Body>
    </soap:Envelope>
    

    Apart from this I changed the name to the parameter by "oReq", like this:

    public ConsultarRecibosPendientesRes ConsultarRecibosPendientes(
                                  @WebParam(name = "oReq", targetNamespace = "")
                                  ConsultarRecibosPendientesReq oReq) {...}