Spring Boot SOAP Web 服务帮助请求

问题描述 投票:0回答:1

我尝试学习如何制作 Spring Boot SOAP Web 服务。我跟随 this描述和我修改了这个项目的源代码。 A 将 addRequest 添加到 XSD 并生成 java 类。但是当我尝试使用 SoapUI 调用添加操作时,我收到错误代码 404。原始的 StudentDetailRequest 工作正常。

学生 wsdl 位于 http://localhost:8080/service/studentDetailsWsdl.wsdl

enter image description here

enter image description here

CalculatorEndpoint 看起来像这样:

package com.howtodoinjava.endpoints;

import com.howtodoinjava.repository.CalculatorService;
import com.howtodoinjava.repository.StudentRepository;
import com.howtodoinjava.xml.school.AddRequest;
import com.howtodoinjava.xml.school.AddResponse;
import com.howtodoinjava.xml.school.StudentDetailsRequest;
import com.howtodoinjava.xml.school.StudentDetailsResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

@Endpoint
public class CalculatorEndpoint
{
  private static final String NAMESPACE_URI = "http://www.howtodoinjava.com/xml/school";
  private final CalculatorService calculatorService;

  @Autowired
  public CalculatorEndpoint(CalculatorService calculatorService) {
    this.calculatorService = calculatorService;
  }

  @PayloadRoot(namespace = NAMESPACE_URI, localPart = "AddRequest")
  @ResponsePayload
  public AddResponse add(@RequestPayload AddRequest request) {
    AddResponse response = new AddResponse();
    response.setReturn(this.calculatorService.add(request.getA(),request.getB()));
    return response;
  }
}

经过我修改的 Git 存储库位于 here。另一个项目是 here,用于我尝试过的简单 addRequest。如果我尝试在浏览器中加载 http://localhost:8080/ws/calculator-service ,我会收到 405 错误代码。 (此 wsdl 位于 http://localhost:8080/ws/CalculatorServiceWsdl.wsdl

enter image description here

不太了解Spring SOAP服务的机制。接下来我可以尝试什么?

spring-boot soap
1个回答
0
投票

好的,我这样修改了一行:

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "addRequest")

(小写“addRequest”)现在可以使用了。

© www.soinside.com 2019 - 2024. All rights reserved.