Spring Web 服务客户端和服务器 - 未找到端点映射

2024-04-15

我正在尝试将基于 Spring WS 的服务器和基于 Spring WS 的客户端连接在一起。在服务器上使用 org.codehaus.mojo:jaxb2-maven-plugin 在客户端上使用 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin 。

Error:

警告:找不到 [SaajSoapMessage { 的端点映射http://localhost:10301/0301-ws-xmlconfig-service http://localhost:10301/0301-ws-xmlconfig-service}用户请求]

这是我的 Spring WS 服务器配置:

用户详细信息.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  attributeFormDefault="unqualified" elementFormDefault="qualified"
  targetNamespace="http://localhost:10301/0301-ws-xmlconfig-service">

  <xs:element name="UserDetailsResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element type="xs:NCName" name="FirstName" />
        <xs:element type="xs:NCName" name="LastName" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="UserRequest">
    <xs:complexType>
      <xs:attribute name="Email">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:pattern value="[^@]+@[^\.]+\..+" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:complexType>
  </xs:element>

</xs:schema>

用户端点.java:

package net.lkrnac.server;

import localhost._10301._0301_ws_xmlconfig_service.UserDetailsResponse;

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 UserEndpoint {
  @PayloadRoot(namespace = "http://localhost:10301/0301-ws-xmlconfig-service/", localPart = "getUserDetails")
  @ResponsePayload
  public UserDetailsResponse getUserDetails(@RequestPayload String userEmail) {
    UserDetailsResponse userDetails = null;
    if ("[email protected] /cdn-cgi/l/email-protection".equals(userEmail)) {
       userDetails = new UserDetailsResponse();
       userDetails.setFirstName("Lubos");
       userDetails.setLastName("Krnac");
    }
    return userDetails;
  }
}

网络服务配置.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:ws="http://www.springframework.org/schema/web-services"
  xsi:schemaLocation="http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">

  <context:component-scan base-package="net.lkrnac.server" />

  <ws:annotation-driven />
</beans>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  version="2.5">
  <display-name>0301-ws-xmlconfig-service</display-name>
  <servlet>
    <servlet-name>web-service</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet
    </servlet-class>
    <init-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>classpath:web-service-config.xml</param-value>
    </init-param>
    <init-param>
       <param-name>transformWsdlLocations</param-name>
       <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
     <servlet-name>web-service</servlet-name>
     <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>

这是我的客户端配置:

WebServiceClient.java:

package net.lkrnac.client;

import javax.annotation.PostConstruct;

import net.lkrnac.model.UserDetailsResponse;
import net.lkrnac.model.UserRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Component;
import org.springframework.ws.client.core.WebServiceTemplate;

@Component
@EnableAutoConfiguration
public class WebServiceClient {
  private static final Logger log = LoggerFactory
      .getLogger(WebServiceClient.class);

  private static final String URL =
      "http://localhost:10301/0301-ws-xmlconfig-service/getUserDetails";
  private WebServiceTemplate webServiceTemplate;

  @Autowired
  public WebServiceClient(WebServiceTemplate webServiceTemplate) {
     this.webServiceTemplate = webServiceTemplate;
  }

  public UserDetailsResponse getUserDetails(String email) {
    UserRequest request = new UserRequest();
    request.setEmail(email);

    UserDetailsResponse userDetails =
        (UserDetailsResponse) webServiceTemplate.marshalSendAndReceive(URL,
            request);
    return userDetails;
  }

  @PostConstruct
  public void test() {
    UserDetailsResponse userDetails =
        this.getUserDetails("[email protected] /cdn-cgi/l/email-protection");
    log.debug("User Details: " + userDetails.getFirstName() + " "
        + userDetails.getLastName());
  }
}

网络客户端配置.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:web-services="http://www.springframework.org/schema/web-services"
  xsi:schemaLocation="http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">

  <context:component-scan base-package="net.lkrnac.client"/>

  <web-services:annotation-driven/>
  <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
     <property name="contextPath" value="net.lkrnac.model"/>
  </bean>

  <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
     <property name="marshaller" ref="marshaller"/>
     <property name="unmarshaller" ref="marshaller"/>
  </bean>
</beans>

有人知道吗?


日志消息指出端点应该与namespace="http://localhost:10301/0301-ws-xmlconfig-service"并且正在期待UserRequest,所以 localPart 应该匹配UserRequest.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Web 服务客户端和服务器 - 未找到端点映射 的相关文章

随机推荐

  • GIT 和推送忽略的文件

    使用 git 时必须遵循的具体程序是什么 我将给出我的程序 不知何故 它工作得不太顺利 cloned a repository works fine added settings files to gitignore to prevent
  • IntelliJ 结构搜索和替换问题

    有没有一种简单的方法来捕获类型 我似乎无法做一些基本的事情 例如并排使用变量表达式 例如 mapType mapEnd 做一个简单的替换 这可能有什么原因吗 也就是说 如果我有一个表达式 比如 s abc 我把它分成两个变量 s and a
  • 受密码保护的 pdf 中密码字段不可见

    我正在使用 PDF 套件框架来显示 编辑 pdf 文件 它在 macOS 10 12 上严重损坏 有时受密码保护的文件不显示密码字段 有时密码字段在普通文件中可见 我可以使用未记录的 API 来修复此问题 它的问题与隐藏 取消隐藏密码视图有
  • javax.net.ssl.SSLException:SSLSocketFactory 为 null

    我的以下代码有问题 System setProperty javax net ssl keyStoreType pkcs12 System setProperty javax net ssl trustStoreType jks Syste
  • 从核心数据中获取子项总和

    假设我有三个实体 Person 姓名 地址 对多工资 和 对多贷款 Salary 收入 税 相对 对一个人 Bills数量 相对 对一个人 如何执行获取结果如下 John Doe SUM gt 收入 SUM gt 金额 Eva Doe SU
  • ES2015 (ES6) `class` 语法有什么好处?

    我对 ES6 类有很多疑问 使用有什么好处class句法 我读到 public private static 将成为 ES7 的一部分 这是一个原因吗 而且 是class一种不同类型的 OOP 或者它仍然是 JavaScript 的原型继承
  • Android 收到新电子邮件时如何执行一些代码?

    在 Android 中 当新电子邮件 gmail 到达时 如何执行一些代码 在 Android 中 当新电子邮件 gmail 到达时 如何执行一些代码 没有记录的广播Intents当 Gmail 到达时发送出去 Gmail 不是 Andro
  • 处理单数和复数控制器/路由

    我对如何在网络应用程序中处理单数和复数路由和控制器感到有点困惑 该网站是一个简单的报价网站 想想爱因斯坦 莎士比亚等 而不是保险 在项目中 我有一个名为 QuoteController 的控制器 控制器名称是单数 那么这是否意味着控制器应该
  • 检查 csv 列中除一项之外的所有项目 [python pandas]

    我试图弄清楚如何使用 python pandas 检查整个列以验证所有值都是整数 除了一个 一行名称始终有一个浮点数 CSV 示例 name num random1 2 random2 3 random3 2 89 random4 1 ra
  • 使用 Volley android 将发布数据发送到服务器

    我正在尝试使用 Volley 库向服务器发送一些数据 private void registerUser final String email final String username final String password Tag
  • Shadow dom 内的 FontAwesome svg

    我正在尝试在 Web 组件中使用 font Awesome js svg 库 但图标不会显示 这可能吗 我正在尝试在现有的 webforms 项目中实现一个角度组件 而无需 css 和脚本 流血 关于如何做到这一点还有其他建议吗 ifram
  • 如何使用 gtest 对 std::bind 函数进行单元测试?

    我正在尝试为项目中的一些 cpp 文件编写单元测试用例 这里的场景是 我有一个 cpp 文件 只定义了一个公共方法 然后又调用私有方法 这里私有方法在公共方法中作为回调方法被调用 我如何在这里测试私有方法 我将对回调指针进行模拟 但我不知道
  • 如何更新 ListView 中的单行?

    我有一个ListView显示新闻项目 它们包含图像 标题和一些文本 图像加载在一个单独的线程中 带有队列和所有 当下载图像时 我现在调用notifyDataSetChanged 在列表适配器上更新图像 这可行 但是getView 被调用太频
  • .NET Core依赖注入,解析泛型接口

    我在 ASP NET Core 依赖注入方面遇到问题 无法解析 IServiceProvider 的通用接口 这是我的设置 通用接口 public interface IRequest
  • 有没有办法在表达式树中设置“DeclaringType”?

    我正在做一个Func gt 表达 gt Func转换 如果我从方法 下面的第一个示例 创建 Func 它工作得很好 但是如果我使用表达式树 第二个示例 创建函数 它会失败并显示空引用异常当访问时func2 Method DeclaringT
  • 使用字符向量索引命名数据帧的嵌套列表 - R

    我有一个命名数据框的嵌套列表 如下所示 mylist2 lt list list df1 a data frame replicate 2 sample 0 1 5 rep TRUE df2 b data frame replicate 2
  • 在命令行上构建 Windows 8 Phone 应用程序

    我目前正在将现有的跨平台框架移植到 Windows Phone 8 构建过程是完全自动化的 我们使用的是坚如磐石的 CI 系统 我可以从 Visual Studio Express 2012 构建和部署 Windows Phone 8 示例
  • 帮助我使用 jquery 验证插件的远程方法

    任何人都可以帮助我使用jquery远程 验证方法 我的意思是我知道如何在 jquery 部分使用它 谁能告诉我服务器端部分 我正在使用 PHP 和 codeigniter 来做到这一点 考虑下面的例子 myform validate rul
  • 如何使用 jQuery Uniform 库取消选中复选框

    我在取消选中时遇到问题checkbox 看一下我的jsFiddle http jsfiddle net r87NH 我正在尝试 check2 attr checked true I use uniform http pixelmatrixd
  • Spring Web 服务客户端和服务器 - 未找到端点映射

    我正在尝试将基于 Spring WS 的服务器和基于 Spring WS 的客户端连接在一起 在服务器上使用 org codehaus mojo jaxb2 maven plugin 在客户端上使用 org jvnet jaxb2 mave