当前位置: 首页 > 知识库问答 >
问题:

Spring-boot Web服务endpoint类不工作

公西修文
2023-03-14

使用spring-boot-web-services依赖项。当应用程序启动时,我可以正确地看到wsdl,但当我使用chrome wizdler进行适当输入时,我会失败。甚至无法看到endpoint类中的print语句。

需要确认我是否基于WSDL为注释@PayloadRoot、@RequestPayload和@ResponsePayload提供了正确的值。

下面是我的WSDL和endpoint类:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="schemas.corporate.com/col/2014/01" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="VaultNotificationService" targetNamespace="schemas.corporate.com/col/2014/01">
   <wsp:Policy wsu:Id="BasicHttpBinding_IVaultNotificationService_policy">
      <wsp:ExactlyOne>
         <wsp:All>
            <sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
               <wsp:Policy>
                  <sp:TransportToken>
                     <wsp:Policy>
                        <sp:HttpsToken RequireClientCertificate="false" />
                     </wsp:Policy>
                  </sp:TransportToken>
                  <sp:AlgorithmSuite>
                     <wsp:Policy>
                        <sp:Basic256 />
                     </wsp:Policy>
                  </sp:AlgorithmSuite>
                  <sp:Layout>
                     <wsp:Policy>
                        <sp:Strict />
                     </wsp:Policy>
                  </sp:Layout>
               </wsp:Policy>
            </sp:TransportBinding>
         </wsp:All>
      </wsp:ExactlyOne>
   </wsp:Policy>
   <wsdl:types>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:CorporateServices" elementFormDefault="qualified" targetNamespace="urn:CorporateServices">
         <xs:element name="OrderUpdate">
            <xs:complexType>
               <xs:sequence>
                  <xs:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="OrderUpdateItemList" type="tns:OrderUpdateItem" />
               </xs:sequence>
            </xs:complexType>
         </xs:element>
         <xs:complexType name="OrderUpdateItem">
            <xs:sequence>
               <xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="Order_ID" type="xs:string" />
               <xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="Order_InternalID" type="xs:string" />
               <xs:element minOccurs="0" maxOccurs="1" form="unqualified" name="Order_Status" type="xs:string" />
            </xs:sequence>
         </xs:complexType>
         <xs:element name="OrderUpdateResponse">
            <xs:complexType>
               <xs:sequence>
                  <xs:element minOccurs="0" maxOccurs="unbounded" form="unqualified" name="OrderUpdateItemList" type="tns:OrderUpdateItem" />
               </xs:sequence>
            </xs:complexType>
         </xs:element>
      </xs:schema>
   </wsdl:types>
   <wsdl:message name="UpdateRequest">
      <wsdl:part xmlns:q1="urn:CorporateServices" name="parameters" element="q1:OrderUpdate" />
   </wsdl:message>
   <wsdl:message name="UpdateResponse">
      <wsdl:part xmlns:q2="urn:CorporateServices" name="parameters" element="q2:OrderUpdateResponse" />
   </wsdl:message>
   <wsdl:portType name="IVaultNotificationService">
      <wsdl:operation name="Update">
         <wsdl:input wsaw:Action="schemas.corporate.com/col/2014/01/IVaultNotificationService/Update" name="UpdateRequest" message="tns:UpdateRequest" />
         <wsdl:output wsaw:Action="schemas.corporate.com/col/2014/01/IVaultNotificationService/UpdateResponse" name="UpdateResponse" message="tns:UpdateResponse" />
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="BasicHttpBinding_IVaultNotificationService" type="tns:IVaultNotificationService">
      <wsp:PolicyReference URI="#BasicHttpBinding_IVaultNotificationService_policy" />
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
      <wsdl:operation name="Update">
         <soap:operation soapAction="schemas.corporate.com/col/2014/01/IVaultNotificationService/Update" style="document" />
         <wsdl:input name="UpdateRequest">
            <soap:body use="literal" />
         </wsdl:input>
         <wsdl:output name="UpdateResponse">
            <soap:body use="literal" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="VaultNotificationService">
      <wsdl:port name="BasicHttpBinding_IVaultNotificationService" binding="tns:BasicHttpBinding_IVaultNotificationService">
         <soap:address location="https://app.sit.col.corporate.com/VaultNotificationService.svc" />
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>
import java.util.List;
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;

import colservices.OrderUpdate;
import colservices.OrderUpdateItem;
import colservices.OrderUpdateResponse;

@Endpoint
public class OrderUpdateEndpoint {

    private final IVaultNotificationService vaultNotificationService;

    @Autowired
    public OrderUpdateEndpoint(IVaultNotificationService vaultNotificationService) {
        this.vaultNotificationService = vaultNotificationService;
    }

    @PayloadRoot(namespace = "urn:CorporateServices", localPart = "UpdateRequest")
    @ResponsePayload
    public OrderUpdateResponse updateOrderStatus(@RequestPayload OrderUpdate request) {
    System.out.println("Enetered in endpoint");
        List<OrderUpdateItem> orderUpdateItemList = vaultNotificationService
                .updateOrdersStatus(request.getOrderUpdateItemList());

        OrderUpdateResponse response = new OrderUpdateResponse();
        response.getOrderUpdateItemList().addAll(orderUpdateItemList);

        return response;
    }

}
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;

@EnableWs
@Configuration
public class ApplicationConfig extends WsConfigurerAdapter {

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

    @Bean(name = "orderStatusUpdator")
    public Wsdl11Definition defaultWsdl11Definition() {
        SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
        wsdl11Definition.setWsdl(new ClassPathResource("vaultNotificationService.wsdl"));
        return wsdl11Definition;
    }
}

应用程序

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        System.out.println("entering application");
        SpringApplication.run(Application.class, args);
    }
}

共有1个答案

戎亦
2023-03-14

得到了以下更改:

1)在WSDL中从

<soap:address location="https://app.sit.col.corporate.com/VaultNotificationService.svc" />

 <soap:address location="https://app.sit.col.travelex.com/services" />
 类似资料:
  • 我目前正在设置一些Spring boot应用程序,其中一个将是配置服务器,其他将是客户端。例如: 配置服务器 资源服务器 web ui(也是一个带有Spring Security和apache互动程序的引导应用程序) 我面临的问题是,在web ui中,执行器endpoint不工作,它们给出了401个错误。 web ui中Spring Security配置的以下代码id Spring配置代码 项目b

  • 我使用的是Spring Boot v2。5.2微服务并尝试动态刷新endpoint。我正在使用Spring Cloud API Gateway并实现了安全性,现在当我http://localhost:8012/actuator/busrefresh,我看到只有Spring Cloud API gateway反映了这些变化,但其他微服务没有。 我们如何修复它? Spring Cloud API网关

  • 我一定错过了一些简单的东西,但是我很难将Autowired属性分配给bean。这里贴出的所有类似答案似乎都围绕着三种解决方案之一: null 我试图制作一个最简的bean来表示我的DAO并将其注入到Web服务中。 DAO接口: DAO实现: 我错过了什么?

  • 让Nginx入口控制器在我的Kubernetes集群中工作时遇到了一些问题。我已经创建了nginx入口部署、服务、角色等,根据https://kubernetes.github.io/ingress-nginx/deploy/ 我还部署了一个简单的hello world应用程序,它可以监听端口8080 并为其创建了服务 最后,我创建了一个TLS机密(

  • 我有一个spring soap web服务,我想使用自定义日志记录方面来度量它的性能。对于普通的spring bean来说,这个方面工作得很好,但是对于Endpoint-InvokeInterral方法,这个方面没有被调用。像保护方法一样在Spring有什么限制吗?谢谢你帮我把它弄好? 代码示例: Spring WS终结点: 更新:将访问修饰符更改为public,这是否意味着Spring允许AOP

  • 类名: Imi\Server\Server 服务器工具类 方法 getServer 获取服务器 $server = Server::getServer(); // 获取当前服务器 $server = Server::getServer('serverName'); // 获取指定名称的服务器 sendMessage 发送消息给 Worker 进程,使用框架内置格式 返回成功发送消息数量 // 发