英文:
SOAP Web Service with Custom Class Argument in Java 8 and Glassfish 5
问题
我试图开发一个带有自定义类的SOAP服务...
但是,我无法检查生成的WSDL。
package org.bz.soap.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import org.bz.soap.api.models.Empleado1;
@WebService
public interface IWebService {
@WebMethod
void create(Empleado1 empleado1);
@WebMethod
int sumar(int a, int b);
}
现在是实现源代码:
package org.bz.soap.ws;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.jws.WebService;
import org.bz.soap.api.models.Empleado1;
import org.bz.soap.api.models.service.IEmpleadoService;
@Stateless
@WebService(endpointInterface = "org.bz.soap.ws.IWebService")
public class WebServiceImpl implements IWebService {
@Inject
IEmpleadoService empleadoService;
@Override
public void create(Empleado1 empleado1) {
System.out.println(this.getClass().getSimpleName().concat(" create"));
}
@Override
public int sumar(int a, int b) {
return a + b;
}
}
带有包的POJO类:
package org.bz.soap.api.models;
import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Empleado1 implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String nombres;
private String tipoDocumento;
private String numeroDocumento;
private Date fechaNacimiento;
public Empleado1() {
}
// Getter 和 Setter 方法...
}
我正在GlassFish中部署:
http://localhost:8080/WebServiceImplService/WebServiceImpl?wsdl
WSDL文件:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is Metro/2.4.0 (wsit240-7e98ff4; 2017-08-03T21:19:54+0200) JAXWS-RI/2.3.0 JAXWS-API/2.3.0 JAXB-RI/2.3.0 JAXB-API/2.3.0 svn-revision#unknown. -->
<!-- Generated by JAX-WS RI (http://javaee.github.io/metro-jax-ws). RI's version is Metro/2.4.0 (wsit240-7e98ff4; 2017-08-03T21:19:54+0200) JAXWS-RI/2.3.0 JAXWS-API/2.3.0 JAXB-RI/2.3.0 JAXB-API/2.3.0 svn-revision#unknown. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.soap.bz.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.soap.bz.org/" name="WebServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://ws.soap.bz.org/" schemaLocation="http://localhost:8080/WebServiceImplService/WebServiceImpl?xsd=1"/>
</xsd:schema>
</types>
<message name="create">
<part name="parameters" element="tns:create"/>
</message>
<!-- 其他 message 定义... -->
<portType name="IWebService">
<!-- 其他 operation 定义... -->
</portType>
<binding name="WebServiceImplPortBinding" type="tns:IWebService">
<!-- 其他 binding 定义... -->
</binding>
<service name="WebServiceImplService">
<!-- 其他 service 定义... -->
</service>
</definitions>
为什么没有描述完整的POJO类?
英文:
I was trying to develop a Soap Service with Custom Class...
But, I can't to check de WSDL generated.
package org.bz.soap.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
import org.bz.soap.api.models.Empleado1;
@WebService
public interface IWebService {
@WebMethod
void create(Empleado1 empleado1);
@WebMethod
int sumar(int a, int b);
}
Now the implementation source code
package org.bz.soap.ws;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.jws.WebService;
import org.bz.soap.api.models.Empleado1;
import org.bz.soap.api.models.service.IEmpleadoService;
@Stateless
@WebService(endpointInterface = "org.bz.soap.ws.IWebService")
public class WebServiceImpl implements IWebService {
@Inject
IEmpleadoService empleadoService;
@Override
public void create(Empleado1 empleado1) {
System.out.println(this.getClass().getSimpleName().concat(" create"));
}
@Override
public int sumar(int a, int b) {
return a + b;
}
}
The POJO class with the packages
package org.bz.soap.api.models;
import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Empleado1 implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String nombres;
private String tipoDocumento;
private String numeroDocumento;
private Date fechaNacimiento;
public Empleado1() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNombres() {
return nombres;
}
public void setNombres(String nombres) {
this.nombres = nombres;
}
public String getTipoDocumento() {
return tipoDocumento;
}
public void setTipoDocumento(String tipoDocumento) {
this.tipoDocumento = tipoDocumento;
}
public String getNumeroDocumento() {
return numeroDocumento;
}
public void setNumeroDocumento(String numeroDocumento) {
this.numeroDocumento = numeroDocumento;
}
public Date getFechaNacimiento() {
return fechaNacimiento;
}
public void setFechaNacimiento(Date fechaNacimiento) {
this.fechaNacimiento = fechaNacimiento;
}
}
I was deploying in glassfish
http://localhost:8080/WebServiceImplService/WebServiceImpl?wsdl
The WSDL file:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is Metro/2.4.0 (wsit240-7e98ff4; 2017-08-03T21:19:54+0200) JAXWS-RI/2.3.0 JAXWS-API/2.3.0 JAXB-RI/2.3.0 JAXB-API/2.3.0 svn-revision#unknown. -->
<!-- Generated by JAX-WS RI (http://javaee.github.io/metro-jax-ws). RI's version is Metro/2.4.0 (wsit240-7e98ff4; 2017-08-03T21:19:54+0200) JAXWS-RI/2.3.0 JAXWS-API/2.3.0 JAXB-RI/2.3.0 JAXB-API/2.3.0 svn-revision#unknown. -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.soap.bz.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.soap.bz.org/" name="WebServiceImplService">
<types>
<xsd:schema>
<xsd:import namespace="http://ws.soap.bz.org/" schemaLocation="http://localhost:8080/WebServiceImplService/WebServiceImpl?xsd=1"/>
</xsd:schema>
</types>
<message name="create">
<part name="parameters" element="tns:create"/>
</message>
<message name="createResponse">
<part name="parameters" element="tns:createResponse"/>
</message>
<message name="sumar">
<part name="parameters" element="tns:sumar"/>
</message>
<message name="sumarResponse">
<part name="parameters" element="tns:sumarResponse"/>
</message>
<portType name="IWebService">
<operation name="create">
<input wsam:Action="http://ws.soap.bz.org/IWebService/createRequest" message="tns:create"/>
<output wsam:Action="http://ws.soap.bz.org/IWebService/createResponse" message="tns:createResponse"/>
</operation>
<operation name="sumar">
<input wsam:Action="http://ws.soap.bz.org/IWebService/sumarRequest" message="tns:sumar"/>
<output wsam:Action="http://ws.soap.bz.org/IWebService/sumarResponse" message="tns:sumarResponse"/>
</operation>
</portType>
<binding name="WebServiceImplPortBinding" type="tns:IWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="create">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="sumar">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="WebServiceImplService">
<port name="WebServiceImplPort" binding="tns:WebServiceImplPortBinding">
<soap:address location="http://localhost:8080/WebServiceImplService/WebServiceImpl"/>
</port>
</service>
</definitions>
Why, Is not described the complete POJO class?
答案1
得分: 0
这个 WSDL 使用了以下导入:
<xsd:import namespace="http://ws.soap.bz.org/" schemaLocation="http://localhost:8080/WebServiceImplService/WebServiceImpl?xsd=1"/>
而你的模式的部分内容在另一个 XSD 文件中,可以在这里访问 - http://localhost:8080/WebServiceImplService/WebServiceImpl?xsd=1
。
英文:
This wsdl uses the following import:
<xsd:import namespace="http://ws.soap.bz.org/" schemaLocation="http://localhost:8080/WebServiceImplService/WebServiceImpl?xsd=1"/>
And part of your schema is in another xsd file that can be accessed here - http://localhost:8080/WebServiceImplService/WebServiceImpl?xsd=1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论