如何解决春季5,SoapFaultClientException:没有终结点适配器,使用注释公开SOAP,使用REST
我正在听这篇文章https://howtodoinjava.com/spring-boot/spring-boot-soap-webservice-example/和这篇https://howtodoinjava.com/spring-boot/spring-soap-client-webservicetemplate/,还看到了这些视频(所有文章都没有使用JAXBElement
这样的答案https://stackoverflow.com/a/30167948/1410223)>
- https://www.youtube.com/watch?v=mr_2-AWYCoc
- https://www.youtube.com/watch?v=ceSqN3CWd14与https://www.youtube.com/watch?v=WJg3NUwq6zU
- https://www.youtube.com/watch?v=LMi3GlKbrHs
我正在审查SOAP
服务,我想找出我的错误。
我收到此错误,但找不到解决方法
[2m2020-09-22 07:12:46.739[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36m.WebServiceMessageReceiverHandlerAdapter[0;39m [2m:[0;39m Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection@325101e9] at [http://localhost:8082/empleadoSOAP]
[2m2020-09-22 07:12:46.741[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.ws.server.MessageTracing.received [0;39m [2m:[0;39m Received request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:empleadoRequestMethod xmlns:ns2="http://template.soap.bz.org"/></SOAP-ENV:Body></SOAP-ENV:Envelope>]
[2m2020-09-22 07:12:46.742[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36myloadRootAnnotationMethodEndpointMapping[0;39m [2m:[0;39m Looking up endpoint for [{http://template.soap.bz.org}empleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.soap.server.SoapMessageDispatcher [0;39m [2m:[0;39m Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@14f8d6f4] maps request to endpoint [public org.bz.soap.generated.classes.EmpleadoResponseMethod org.bz.soap.service.EmpleadoEndpoint.getInfoEmpleado(org.bz.soap.generated.classes.EmpleadoRequestMethod)]
[2m2020-09-22 07:12:46.742[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.soap.server.SoapMessageDispatcher [0;39m [2m:[0;39m Testing endpoint adapter [org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter@4362665e]
[2m2020-09-22 07:12:46.742[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.e.a.DefaultMethodEndpointAdapter[0;39m [2m:[0;39m Testing if argument resolver [org.springframework.ws.server.endpoint.adapter.method.dom.DomPayloadMethodProcessor@50ba93df] supports [class org.bz.soap.generated.classes.EmpleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.e.a.DefaultMethodEndpointAdapter[0;39m [2m:[0;39m Testing if argument resolver [org.springframework.ws.server.endpoint.adapter.method.MessageContextMethodArgumentResolver@2fe27d0f] supports [class org.bz.soap.generated.classes.EmpleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.e.a.DefaultMethodEndpointAdapter[0;39m [2m:[0;39m Testing if argument resolver [org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor@6dc3564a] supports [class org.bz.soap.generated.classes.EmpleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.e.a.DefaultMethodEndpointAdapter[0;39m [2m:[0;39m Testing if argument resolver [org.springframework.ws.server.endpoint.adapter.method.XPathParamMethodArgumentResolver@261d062e] supports [class org.bz.soap.generated.classes.EmpleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.e.a.DefaultMethodEndpointAdapter[0;39m [2m:[0;39m Testing if argument resolver [org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver@22bd4d59] supports [class org.bz.soap.generated.classes.EmpleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.e.a.DefaultMethodEndpointAdapter[0;39m [2m:[0;39m Testing if argument resolver [org.springframework.ws.soap.server.endpoint.adapter.method.SoapHeaderElementMethodArgumentResolver@1e8b5604] supports [class org.bz.soap.generated.classes.EmpleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.e.a.DefaultMethodEndpointAdapter[0;39m [2m:[0;39m Testing if argument resolver [org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor@698d3299] supports [class org.bz.soap.generated.classes.EmpleadoRequestMethod]
[2m2020-09-22 07:12:46.742[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36ms.e.SoapFaultAnnotationExceptionResolver[0;39m [2m:[0;39m Resolving exception from endpoint [public org.bz.soap.generated.classes.EmpleadoResponseMethod org.bz.soap.service.EmpleadoEndpoint.getInfoEmpleado(org.bz.soap.generated.classes.EmpleadoRequestMethod)]: java.lang.IllegalStateException: No adapter for endpoint [public org.bz.soap.generated.classes.EmpleadoResponseMethod org.bz.soap.service.EmpleadoEndpoint.getInfoEmpleado(org.bz.soap.generated.classes.EmpleadoRequestMethod)]: Is your endpoint annotated with @Endpoint,or does it implement a supported interface like MessageHandler or PayloadEndpoint?
[2m2020-09-22 07:12:46.742[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.s.s.e.SimpleSoapExceptionResolver [0;39m [2m:[0;39m Resolving exception from endpoint [public org.bz.soap.generated.classes.EmpleadoResponseMethod org.bz.soap.service.EmpleadoEndpoint.getInfoEmpleado(org.bz.soap.generated.classes.EmpleadoRequestMethod)]: java.lang.IllegalStateException: No adapter for endpoint [public org.bz.soap.generated.classes.EmpleadoResponseMethod org.bz.soap.service.EmpleadoEndpoint.getInfoEmpleado(org.bz.soap.generated.classes.EmpleadoRequestMethod)]: Is your endpoint annotated with @Endpoint,or does it implement a supported interface like MessageHandler or PayloadEndpoint?
[2m2020-09-22 07:12:46.743[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.soap.server.SoapMessageDispatcher [0;39m [2m:[0;39m Endpoint invocation resulted in exception - responding with Fault
java.lang.IllegalStateException: No adapter for endpoint [public org.bz.soap.generated.classes.EmpleadoResponseMethod org.bz.soap.service.EmpleadoEndpoint.getInfoEmpleado(org.bz.soap.generated.classes.EmpleadoRequestMethod)]: Is your endpoint annotated with @Endpoint,or does it implement a supported interface like MessageHandler or PayloadEndpoint?
at org.springframework.ws.server.MessageDispatcher.getEndpointAdapter(MessageDispatcher.java:302) ~[spring-ws-core-3.0.10.RELEASE.jar:na]
at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:235) ~[spring-ws-core-3.0.10.RELEASE.jar:na]
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:176) ~[spring-ws-core-3.0.10.RELEASE.jar:na]
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:89) ~[spring-ws-core-3.0.10.RELEASE.jar:na]
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:61) ~[spring-ws-core-3.0.10.RELEASE.jar:na]
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:293) ~[spring-ws-core-3.0.10.RELEASE.jar:na]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) ~[tomcat-embed-core-9.0.38.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.38.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.38.jar:9.0.38]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.38.jar:9.0.38]
at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
[2m2020-09-22 07:12:46.744[0;39m [32mTRACE[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.ws.server.MessageTracing.sent [0;39m [2m:[0;39m Sent response [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring xml:lang="en">No adapter for endpoint [public org.bz.soap.generated.classes.EmpleadoResponseMethod org.bz.soap.service.EmpleadoEndpoint.getInfoEmpleado(org.bz.soap.generated.classes.EmpleadoRequestMethod)]: Is your endpoint annotated with @Endpoint,or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>] for request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:empleadoRequestMethod xmlns:ns2="http://template.soap.bz.org"/></SOAP-ENV:Body></SOAP-ENV:Envelope>]
[2m2020-09-22 07:12:46.745[0;39m [32mDEBUG[0;39m [35m26524[0;39m [2m---[0;39m [2m[nio-8082-exec-3][0;39m [36mo.s.w.t.http.MessageDispatcherServlet [0;39m [2m:[0;39m Completed 500 INTERNAL_SERVER_ERROR,headers={masked}
我阅读了这个答案https://stackoverflow.com/a/46314260/1410223和这个问题Spring ws: No adapter for endpoint(基于xml配置)。
这是我的xsd
文件。
<element name="empleadoRequest"
type="tns:empleadoRequestMethod">
</element>
<complexType name="empleadoRequestMethod">
<sequence>
<element name="empleado" type="tns:Empleado"></element>
</sequence>
</complexType>
<complexType name="Empleado">
<sequence>
<element name="id" type="long"></element>
<element name="nombres" type="string"></element>
<element name="apellidos" type="string"></element>
<element name="tipoDocumento" type="string"></element>
<element name="numeroDocumento" type="string"></element>
<element name="fechaNacimiento" type="dateTime"></element>
<element name="fechaVinculacion" type="dateTime"></element>
<element name="cargo" type="string"></element>
<element name="salario" type="double"></element>
</sequence>
</complexType>
<element name="empleadoResponse"
type="tns:empleadoResponseMethod">
</element>
<complexType name="empleadoResponseMethod">
<sequence>
<element name="infoEmpleado" type="tns:InfoEmpleado"></element>
</sequence>
</complexType>
<complexType name="InfoEmpleado">
<sequence>
<element name="edadEmpleado" type="string"></element>
<element name="tiempoVinculacion" type="string"></element>
</sequence>
</complexType>
服务
我的Configuration
文件
@EnableWs
@Configuration
public class EmpleadoSoapConfigurerAdapter extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
messageDispatcherServlet.setApplicationContext(applicationContext);
messageDispatcherServlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(messageDispatcherServlet,"/empleadoSOAP/*");
}
@Bean(name = "empleadoWsdl")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema empleadoSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setLocationUri("/empleadoSOAP");
wsdl11Definition.setPortTypeName("EmpleadoPort");
wsdl11Definition.setSchema(empleadoSchema);
wsdl11Definition.setTargetNamespace(EmpleadoEndpoint.NAMESPACE_URI);
return wsdl11Definition;
}
@Bean
public XsdSchema schema() {
return new SimpleXsdSchema(new ClassPathResource("xsd/schema.xsd"));
}
}
现在我的Endpoint
班
@Endpoint
public class EmpleadoEndpoint {
private static final Logger LOGGER = Logger.getLogger(EmpleadoEndpoint.class.getName());
public static final String NAMESPACE_URI = "http://template.soap.bz.org";
@PayloadRoot(namespace = NAMESPACE_URI,localPart = "empleadoRequestMethod")
@ResponsePayload
public EmpleadoResponseMethod getInfoEmpleado(@RequestPayload EmpleadoRequestMethod empleadoRequestMethod) {
LOGGER.log(Level.INFO,empleadoRequestMethod.toString().concat("\n -- Recibido!"));
Empleado empleado = empleadoRequestMethod.getEmpleado();
// NOTE: Intentionally I'm not using a separate Service.
// INI Service
InfoEmpleado infoEmpleado = new InfoEmpleado();
infoEmpleado.setTiempoVinculacion(Utils.getStringPeriodo(empleado.getFechaVinculacion().toGregorianCalendar().getTime(),new Date()));
infoEmpleado.setEdadEmpleado(Utils.getStringPeriodo(empleado.getFechaNacimiento().toGregorianCalendar().getTime(),new Date()));
// END Service
EmpleadoResponseMethod empleadoResponseMethod = new EmpleadoResponseMethod();
empleadoResponseMethod.setInfoEmpleado(infoEmpleado);
return empleadoResponseMethod;
}
}
我可以在WSDL
上看到我的http://localhost:8082/empleadoSOAP/empleadoWsdl.wsdl
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://template.soap.bz.org" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://template.soap.bz.org" targetNamespace="http://template.soap.bz.org">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://template.soap.bz.org">
<element name="empleadoRequest" type="tns:empleadoRequestMethod"> </element>
<complexType name="empleadoRequestMethod">
<sequence>
<element name="empleado" type="tns:Empleado"/>
</sequence>
</complexType>
<complexType name="Empleado">
<sequence>
<element name="id" type="long"/>
<element name="nombres" type="string"/>
<element name="apellidos" type="string"/>
<element name="tipoDocumento" type="string"/>
<element name="numeroDocumento" type="string"/>
<element name="fechaNacimiento" type="dateTime"/>
<element name="fechaVinculacion" type="dateTime"/>
<element name="cargo" type="string"/>
<element name="salario" type="double"/>
</sequence>
</complexType>
<element name="empleadoResponse" type="tns:empleadoResponseMethod"> </element>
<complexType name="empleadoResponseMethod">
<sequence>
<element name="infoEmpleado" type="tns:InfoEmpleado"/>
</sequence>
</complexType>
<complexType name="InfoEmpleado">
<sequence>
<element name="edadEmpleado" type="string"/>
<element name="tiempoVinculacion" type="string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="empleadoRequest">
<wsdl:part element="tns:empleadoRequest" name="empleadoRequest"> </wsdl:part>
</wsdl:message>
<wsdl:message name="empleadoResponse">
<wsdl:part element="tns:empleadoResponse" name="empleadoResponse"> </wsdl:part>
</wsdl:message>
<wsdl:portType name="EmpleadoPort">
<wsdl:operation name="empleado">
<wsdl:input message="tns:empleadoRequest" name="empleadoRequest"> </wsdl:input>
<wsdl:output message="tns:empleadoResponse" name="empleadoResponse"> </wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EmpleadoPortSoap11" type="tns:EmpleadoPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="empleado">
<soap:operation soapAction=""/>
<wsdl:input name="empleadoRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="empleadoResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EmpleadoPortService">
<wsdl:port binding="tns:EmpleadoPortSoap11" name="EmpleadoPortSoap11">
<soap:address location="http://localhost:8082/empleadoSOAP"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
正在使用Web服务,网址为http://localhost:8082/empleadoSOAP
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://template.soap.bz.org">
<soapenv:Header/>
<soapenv:Body>
<tem:empleadoRequest>
<tem:empleado>
<tem:id></tem:id>
<tem:nombres>Fulano</tem:nombres>
<tem:apellidos>De Tales</tem:apellidos>
<tem:tipoDocumento>CC</tem:tipoDocumento>
<tem:numeroDocumento>93024555</tem:numeroDocumento>
<tem:fechaNacimiento>2004-03-15</tem:fechaNacimiento>
<tem:fechaVinculacion>2020-09-21</tem:fechaVinculacion>
<tem:cargo>Prueba</tem:cargo>
<tem:salario>75.5</tem:salario>
</tem:empleado>
</tem:empleadoRequest>
</soapenv:Body>
</soapenv:Envelope>
2020-09-22 13:20:07.960 DEBUG 14908 --- [nio-8082-exec-3] .WebServiceMessageReceiverHandlerAdapter : Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection@14027d8a] at [http://localhost:8082/empleadoSOAP]
2020-09-22 13:20:07.969 TRACE 14908 --- [nio-8082-exec-3] o.s.ws.server.MessageTracing.received : Received request [<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://template.soap.bz.org">
<soapenv:Header/>
<soapenv:Body>
<tem:empleadoRequest>
<tem:empleado>
<tem:id/>
<tem:nombres>Fulano</tem:nombres>
<tem:apellidos>De Tales</tem:apellidos>
<tem:tipoDocumento>CC</tem:tipoDocumento>
<tem:numeroDocumento>93024555</tem:numeroDocumento>
<tem:fechaNacimiento>2004-03-15</tem:fechaNacimiento>
<tem:fechaVinculacion>2020-09-21</tem:fechaVinculacion>
<tem:cargo>Prueba</tem:cargo>
<tem:salario>75.5</tem:salario>
</tem:empleado>
</tem:empleadoRequest>
</soapenv:Body>
</soapenv:Envelope>]
2020-09-22 13:20:07.969 DEBUG 14908 --- [nio-8082-exec-3] yloadRootAnnotationMethodEndpointMapping : Looking up endpoint for [{http://template.soap.bz.org}empleadoRequest]
2020-09-22 13:20:07.969 DEBUG 14908 --- [nio-8082-exec-3] o.s.w.soap.server.SoapMessageDispatcher : Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@7b310489] has no mapping for request
2020-09-22 13:20:07.969 DEBUG 14908 --- [nio-8082-exec-3] oapActionAnnotationMethodEndpointMapping : Looking up endpoint for []
2020-09-22 13:20:07.969 DEBUG 14908 --- [nio-8082-exec-3] o.s.w.soap.server.SoapMessageDispatcher : Endpoint mapping [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping@538c39f0] has no mapping for request
2020-09-22 13:20:07.969 DEBUG 14908 --- [nio-8082-exec-3] o.s.w.soap.server.SoapMessageDispatcher : Endpoint mapping [org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping@54fb39f] has no mapping for request
2020-09-22 13:20:07.969 WARN 14908 --- [nio-8082-exec-3] o.s.ws.server.EndpointNotFound : No endpoint mapping found for [SaajSoapMessage {http://template.soap.bz.org}empleadoRequest]
2020-09-22 13:20:07.970 DEBUG 14908 --- [nio-8082-exec-3] o.s.w.t.http.MessageDispatcherServlet : Completed 404 NOT_FOUND,headers={}
客户
我正在使用SOAP
服务中的REST
服务。
public class EmpleadoConnector extends WebServiceGatewaySupport {
public Object callWebService(String url,Object request) {
return getWebServiceTemplate().marshalSendAndReceive(url,request);
}
}
Configuration
类
@Configuration
public class EmpleadoSoapConfigurer {
public static final String URI = "http://localhost:8082/empleadoSOAP";
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("org.bz.soap.generated.classes");
return marshaller;
}
@Bean
public EmpleadoConnector empleadoConnector(Jaxb2Marshaller marshaller) {
EmpleadoConnector empleadoConnector = new EmpleadoConnector();
empleadoConnector.setDefaultUri(URI);
empleadoConnector.setMarshaller(marshaller);
empleadoConnector.setUnmarshaller(marshaller);
return empleadoConnector;
}
}
RestController
类
@RestController
public class RestSoapConsumerController {
private static final Logger LOGGER = Logger.getLogger(RestSoapConsumerController.class.getName());
@Autowired
EmpleadoConnector empleadoConnector;
@PostMapping("/getInfoEmpleado")
public EmpleadoResponseMethod getInfoEmpleado(@RequestBody EmpleadoRequestMethod request) {
LOGGER.log(Level.INFO,request.toString().concat("\n -- Recibido!"));
// NOTE: Intentionally I'm not using a separate Service
EmpleadoResponseMethod response = (EmpleadoResponseMethod) empleadoConnector.callWebService(EmpleadoSoapConfigurer.URI,request);
return response;
}
}
我正在使用REST
上的POSTMAN提供的http://localhost:8083/getInfoEmpleado
服务
注意:我包括了有效载荷,因为也许也是错误的。
{
"nombres": "Orlando Jose ","apellidos": "Rodriguez Rivera","tipoDocumento": "TI","numeroDocumento": "99258732","fechaNacimiento": "2004-03-15","fechaVinculacion": "2020-09-21","cargo": "Vendedor","salario": 8000
}
我知道XSD和端点之间的问题,但是我无法确定要解决的问题。 有人可以帮助我确定问题以便解决这种僵局吗?
编辑1:
在EmpleadoEndpoint
类中进行更改
@PayloadRoot(namespace = NAMESPACE_URI,localPart = "empleadoRequest")
我现在又收到另一个错误:
javax.xml.bind.UnmarshalException: unexpected element (uri:"http://template.soap.bz.org",local:"empleadoRequest"). Expected elements are <{http://template.soap.bz.org}empleado>,<{http://template.soap.bz.org}empleadoRequestMethod>
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:712) ~[jaxb-impl-2.3.3.jar:2.3.3]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。