Hello, I'm trying to implement a WebService and I'm having problem in response. I used SoapUi and it's working. I'm in the step of implementing the WebService client in the application. When I make the request, the response error appears "[class] do not have a property of the name return"
Follow the code:
public static void main(String[] args) {
XmlDoc doc = null;
try {
List<String> documento = Files.readAllLines(Paths.get("C:\Users\Ceser\Desktop\teste.xml"));
WebService1 service = new WebService1();
WebService1Soap soap = service.getWebService1Soap();
soap.inserirPedido(2, (XmlDoc) documento);
} catch (IOException e) {
e.printStackTrace();
}
}
Requisition:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "iTipo", "xmlDoc" })
@XmlRootElement(name = "inserirPedido")
public class InserirPedido {
protected int iTipo;
protected InserirPedido.XmlDoc xmlDoc;
public int getITipo() {
return iTipo;
}
public void setITipo(int value) {
this.iTipo = value;
}
public InserirPedido.XmlDoc getXmlDoc() {
return xmlDoc;
}
public void setXmlDoc(InserirPedido.XmlDoc value) {
this.xmlDoc = value;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "content" })
public static class XmlDoc {
@XmlMixed
@XmlAnyElement(lax = true)
protected List<Object> content;
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
}
}
Answer:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "inserirPedidoResponse")
public class InserirPedidoResponse {
}
EXCEPTION:
Exception in thread "main" javax.xml.ws.WebServiceException: class br.com.caelum.toquews.client.InserirPedidoResponse do not have a property of the name return at com.sun.xml.internal.ws.client.sei.ResponseBuilder $ DocLit (Unknown Source) at com.sun.xml.internal.ws.client.sei.StubHandler.buildResponseBuilder (Unknown Source) (Unknown Source) at com.sun.xml.internal.ws.client.sei.StubHandler. at com.sun.xml.internal.ws.db.DatabindingImpl.initStubHandlers (Unknown Source) at com.sun.xml.internal.ws.db.DatabindingImpl. (Unknown Source) at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create (Unknown Source) at com.sun.xml.internal.ws.db.DatabindingProviderImpl.create (Unknown Source) at com.sun.xml.internal.ws.db.DatabindingFactoryImpl.createRuntime (Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.buildRuntimeModel (Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.createSEIPortInfo (Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.addSEI (Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort (Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort (Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort (Unknown Source) at javax.xml.ws.Service.getPort (Unknown Source) at br.com.caelum.estoquews.cliente.WebService1.getWebService1Soap (WebService1.java:72) at br.com.caelum.estoquews.cliente.TesteWebService.main (TesteWebService.java:23) Caused by: javax.xml.bind.JAXBException: return is not a valid property on class br.ca.edu.edu.edu.InsertPedidoResponse at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor (Unknown Source) at com.sun.xml.internal.ws.db.glassfish.JAXBRIContextWrapper.getElementPropertyAccessor (Unknown Source) ... 17 more