Consumir webservice cliente no netbeans

Web service

Java

NetBeans

13/03/2018

Bom dia, estou precisando consumir um webservice e estou com dificuldade para passar o parâmetro de entrada. Estou usando o netbeans e fiz a importação do arquivo wsdl do webservice. Consigo fazer a chamada e ler o retorno, mas como não estou conseguindo passar o parâmetro de entrada o retorno é um erro pedindo para informar o mesmo.
Segue o código:
<%@page import="javax.xml.bind.JAXBElement"%>
<%@page import="br.com.senior.services.UsuarioobterParametrosVendasIn"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%--
Document : Resposta
Created on : 26/02/2018, 15:08:50
Author : user
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<%-- start web service invocation --%><hr/>
<%
try {
br.com.senior.services.G5SeniorServices service = new br.com.senior.services.G5SeniorServices();
br.com.senior.services.SapiensSynccomSeniorG5CoGerCadUsuario port = service.getSapiensSynccomSeniorG5CoGerCadUsuarioPort();
// TODO initialize WS operation arguments here
java.lang.String user = "samuels";
java.lang.String password = "2812";
int encryption = 0;
br.com.senior.services.UsuarioobterParametrosVendasIn parameters = new UsuarioobterParametrosVendasIn();
// TODO process result here
br.com.senior.services.UsuarioobterParametrosVendasOut result = port.obterParametrosVendas(user, password, encryption, parameters);
out.println("Result = \\n"+result);
out.println("Result = \\n"+result.getErroExecucao().getValue());
out.println("Result = "+result.getResultado().getValue());
} catch (Exception ex) {
// TODO handle custom exceptions here
out.println("Erro = "+ex);
}
%>
<%-- end web service invocation --%><hr/>
</body>
</html>

segue o xsd:

<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown. --><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://services.senior.com.br">

<xs:complexType name="usuarioobterParametrosVendasIn">
<xs:sequence>
<xs:element name="codEmp" type="xs:int" nillable="true" minOccurs="0"/>
<xs:element name="flowInstanceID" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="flowName" type="xs:string" nillable="true" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="usuarioobterParametrosVendasOut">
<xs:sequence>
<xs:element name="codigoResultado" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="erroExecucao" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="obsMob" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="obsMol" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="obsMor" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="resultado" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="venAsp" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="venCpd" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="venLpd" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="venRpd" type="xs:string" nillable="true" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

Então, preciso passar o elemento "CodEmp" que é um inteiro. Tentei usar o seguinte comando parameters.setCodEmp(), mas a parte dentro do parênteses eu não consigo passar o valor.
Alguém sabe como proceder?
Samuel Schlischitng

Samuel Schlischitng

Curtidas 0

Respostas

Marcio Souza

Marcio Souza

13/03/2018

Olá, como assim não consegue passar o valor? Métodos set são exatamente para passagem de valor. Tem algum erro quando faz essa passagem de valor, qual seria?
GOSTEI 0
POSTAR