You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SOAP Web服务SoapUI调用报500错误:端点无适配程序求助

排查SOAP Web服务调用500错误:No adapter for endpoint

错误响应信息

HTTP/1.1 500 
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
SOAPAction: ""
Content-Type: text/xml;charset=utf-8
Content-Length: 539
Date: Sun, 19 Nov 2023 07:46:34 GMT
Connection: close

<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 com.librarysystem.BorrowBookResponse com.example.sm704_1.LibraryEndpoint.borrowBook(com.librarysystem.BorrowBookRequest)]: 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>

SOAP请求内容

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:lib="http://www.librarysystem.com">
<soapenv:Header/>
<soapenv:Body>
  <lib:BorrowBookRequest>
     <member>
        <memberId>12345</memberId>
        <name>Jane Doe</name>
     </member>
     <book>
        <bookId>98765</bookId>
        <title>The Great Adventure</title>
        <author>John Smith</author>
     </book>
     <borrowDate>2023-11-20</borrowDate>
  </lib:BorrowBookRequest>
</soapenv:Body>
</soapenv:Envelope>

Endpoint代码

@Endpoint
public class LibraryEndpoint {

private static final String NAMESPACE_URI = "http://www.librarysystem.com";

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "BorrowBookRequest")
@ResponsePayload
public BorrowBookResponse borrowBook(@RequestPayload @XmlElement(namespace = NAMESPACE_URI, required = true) BorrowBookRequest request) {
    // Implement your business logic or interact with a repository/service
    BorrowBookResponse response = new BorrowBookResponse();
    response.setMessage("Book borrowed successfully.");
    // Set other response fields as needed
    return response;
}

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "ReturnBookRequest")
@ResponsePayload
public ReturnBookResponse returnBook(@RequestPayload @XmlElement(namespace = NAMESPACE_URI, required = true) ReturnBookRequest request) {
    // Implement your business logic or interact with a repository/service
    ReturnBookResponse response = new ReturnBookResponse();
    response.setMessage("Book returned successfully.");
    // Set other response fields as needed
    return response;
}

}

配置类代码

@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {

@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean<>(servlet, "/ws/*");
}

@Bean(name = "library")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema librarySchema) {
    DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
    wsdl11Definition.setPortTypeName("LibraryPort");
    wsdl11Definition.setLocationUri("/ws");
    wsdl11Definition.setTargetNamespace("http://www.librarysystem.com");
    wsdl11Definition.setSchema(librarySchema);
    return wsdl11Definition;
}


@Bean
public XsdSchema librarySchema() {
    return new SimpleXsdSchema(new ClassPathResource("LibrarySystemSchema.xsd"));
}
}

排查方案

  • 确认LibraryEndpoint被Spring扫描:@Endpoint注解的类需要在Spring组件扫描范围内,检查配置类是否添加了@ComponentScan并覆盖该类所在包,或者在配置类中显式注册LibraryEndpoint为Bean。
  • 核对命名空间一致性:确保SOAP请求中的xmlns:lib="http://www.librarysystem.com"、Endpoint中的NAMESPACE_URI、XSD schema中的目标命名空间完全一致,注意大小写、是否有多余斜杠等细节。
  • 简化参数注解:尝试去掉方法参数上的@XmlElement(namespace = NAMESPACE_URI, required = true),仅保留@RequestPayload,Spring-WS通常可自动完成参数绑定。
  • 检查依赖完整性:确认spring-ws-core等核心依赖版本正确,无缺失或冲突。
  • 验证SOAPAction头:在SoapUI请求中添加SOAPAction头,值设为http://www.librarysystem.com/BorrowBookRequest或空字符串,匹配Endpoint的处理规则。
  • 检查XSD schema结构:确保LibrarySystemSchema.xsd中BorrowBookRequest元素的命名空间、字段结构与请求内容完全匹配。

内容的提问来源于stack exchange,提问作者bedirates

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 05:47:04