标签: spring-ws

Spring-ws SOAP 404错误

我在此之后做了一个教程 - > http://java.dzone.com/articles/spring-ws-how 当我转到 url http://localhost:8080/myService/services/MemberDetailsRequest.wsdl时,我得到静态wsdl 文件..但是当我使用 SoapUI 导入 wsdl 文件然后测试它时..我只收到 404 错误,any1 有解决方案吗?

有什么建议吗,为什么我无法通过soapUI 得到任何回复?

spring soap spring-ws soapui

5
推荐指数
1
解决办法
8706
查看次数

出现错误 无法加载架构 abc.xsd。IllegalArgumentException:资源路径 def.xsd 已标准化为 null,这是无效的

我曾经jaxb2-maven-plugin从 xsd 生成 java 类。类正在生成。下面是我的 xsd 文件之一的示例

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns="http://customer.serviceoperations.lmsapi.message.webservice.lms.vu360.softech.com" 
    xmlns:cust="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com"
    xmlns:tr="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:import namespace="http://transactionresult.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/TransactionResultType.xsd"/>
    <xsd:import namespace="http://customer.types.lmsapi.message.webservice.lms.vu360.softech.com" schemaLocation="../types/Customer.xsd"/>

    <xsd:element name="AddCustomerRequest">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Customers" type="cust:Customers" minOccurs="1" maxOccurs="1" nillable="false" />
            </xsd:sequence>
            <xsd:attribute name="key" type="xsd:string" use="required" />
            <xsd:attribute name="ResellerId" type="xsd:nonNegativeInteger" use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="AddCustomerResponse">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="RegisterCustomers" type="cust:RegisterCustomers" minOccurs="0" maxOccurs="1" nillable="false" />
            </xsd:sequence>
            <xsd:attribute name="transactionResult" type="tr:TransactionResultType" use="required"/>
            <xsd:attribute name="transactionResultMessage" type="xsd:string"/>
        </xsd:complexType>
    </xsd:element>

</xsd:schema>
Run Code Online (Sandbox Code Playgroud)

从 xsd 生成类后。我正在尝试建立一个 Spring Web 服务。这是我的 spring 网络服务配置文件

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" …
Run Code Online (Sandbox Code Playgroud)

xsd spring-ws java-8 spring-4

5
推荐指数
1
解决办法
2299
查看次数

日志中漂亮的打印 spring-ws 肥皂消息

我们正在调试一些 spring-ws 肥皂网络服务,并使用本文中突出显示的 log4j 设置输出肥皂请求:

/sf/answers/1232393151/

我想漂亮地打印发送到日志的肥皂消息。有谁知道这是否可以做到,如果可以的话该怎么做?

java soap log4j spring-ws slf4j

5
推荐指数
1
解决办法
1317
查看次数

Spring WS (DefaultWsdl11Definition) 带 void 的 HTTP 状态代码

我们有一个基于 Spring WS 和DefaultWsdl11Definition的(工作的)SOAP Web 服务。

基本上是这样的:

@Endpoint("name")
public class OurEndpoint {

    @PayloadRoot(namespace = "somenamespace", localPart = "localpart")
    public void onMessage(@RequestPayload SomePojo pojo) {
        // do stuff
    }
}
Run Code Online (Sandbox Code Playgroud)

它是在 Spring 中连接的,并且可以正确处理我们所有的 SOAP 请求。唯一的问题是该方法返回202 Accepted。这不是调用者想要的,他宁愿让我们返回204 No Content(或者如果不可能,则返回空的200 OK)。

我们的其他端点有一个有效的响应对象,并且返回200 OK。似乎 void 导致202,而204可能更合适?

是否可以更改 Spring WS 中的响应代码?我们似乎找不到正确的方法来做到这一点。

我们尝试过但不起作用的事情:

  • 将返回类型更改为:
    • HttpStatus.NO_CONTENT
    • org.w3c.dom.Element <- 不接受
  • 添加@ResponseStatus <- 这是用于 MVC,而不是 WS

有任何想法吗?

spring soap web-services spring-ws http-status-codes

5
推荐指数
1
解决办法
4993
查看次数

Spring配置了两个@Endpoint,每个都有一个唯一的wsdl文件

我已经能够使用 wsdl 文件获得一个@Endpoint:

@EnableWs
@Configuration
public class EventServerConfiguration extends WsConfigurerAdapter {
    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/event");
    }


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

    @Bean
    AnnotationActionEndpointMapping endpointMapping() {
        AnnotationActionEndpointMapping mapping = new AnnotationActionEndpointMapping();
        return mapping;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是对于我的用例,我需要处理两个 wsdl 文件。最初我设置了一个 RestController 并从 xml POST 请求中解组了主体,但我现在想尝试纯 spring 方式。

我假设我需要创建两个 MessageDispatcherServlet,每个 wsdl 定义一个,但我不知道如何正确映射或注册我的端点。

有任何想法吗?

摆弄我创建了重复的(具有不同的 wsdl 和 bean 名称)WSDLdefinition …

java spring soap spring-ws endpoint

5
推荐指数
1
解决办法
4564
查看次数

不同 URL 上的多个 Spring WS 端点

我正在使用 Spring Boot,就像示例中的https://spring.io/guides/gs/having-web-service/ WS 端点通过MessageDispatcher 在 /ws/* 上公开:

@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/ws/*");
} 
Run Code Online (Sandbox Code Playgroud)

我想在不同的 URL 上有 2 个端点。那可能吗?

spring spring-ws

5
推荐指数
0
解决办法
340
查看次数

SAAJ0511:由于意外字符,无法从给定源错误创建信封

我在尝试解析 xml 正文的数据部分中包含“\u0001”字符的肥皂请求时收到以下错误:

com.sun.xml.internal.messaging.saaj.soap]: createEnvelope - SAAJ0511: Unable to create envelope from given source

如果没有这个字符,代码可以正常工作。然而,请求来自我无法控制的机器,所以我需要在后端删除这个字符,但我不知道如何。我尝试添加拦截器,但它不起作用,因为它在处理拦截器之前给出了错误。你有什么主意吗?

java soap spring-ws saaj

5
推荐指数
0
解决办法
4349
查看次数

在 Spring WebFlux 中进行异步 SOAP 调用

我有一个使用 WebFlux 和 REST API 的反应式 Spring 应用程序。每当用户调用我的 API 时,我都需要调用公开 WSDL 的 SOAP 服务,执行一些操作并返回结果。

如何将对 SOAP 服务的调用与 Reactive WebFlux 框架结合起来?

在我看来,我可以通过两种不同的方式来做到这一点:

  1. 使用 WebFlux 的 WebClient 构造并发送 SOAP 消息。
  2. 使用 Mono / Flux 中的 WebServiceGatewaySupport 包装同步调用。

第一种方法是我的偏好,但我不知道该怎么做。

这里也提出了类似的问题: Reactive Spring WebClient - Making a SOAP call,它引用了这篇博客文章(https://blog.godatadriven.com/jaxws-reactive-client)。但我无法让这个例子发挥作用。

在 Gradle 插件中使用,wsdl2java我可以使用异步方法创建客户端界面,但我不明白如何使用它。使用时WebServiceGatewaySupport,我根本不使用生成的接口或其方法。相反,我调用通用marshalSendAndReceive方法

public class MySoapClient extends WebServiceGatewaySupport {

    public QueryResponse execute() {
        Query query = new ObjectFactory().createQuery();
        // Further create and set the domain object …
Run Code Online (Sandbox Code Playgroud)

java soap spring-ws spring-webflux spring-reactive

5
推荐指数
1
解决办法
9321
查看次数

Spring-WS WSDL生成问题

我正在尝试创建一个非常简单的Web服务,并且在使spring生成正确的wsdl时遇到一些困难.我已尽力复制本春季教程中的示例.如果有人知道我做错了什么,我真的很感激帮助.

本质上,有一个名为IncidentHeaderEndpoint的EndPoint(目前没有任何功能).我想调用客户端以下列形式发送xml请求:

<browseIncidents>
    <responsibleManager>foo</responsibleManager>
</browseIncidents>
Run Code Online (Sandbox Code Playgroud)

我的EndPoint看起来像这样:

public class IncidentHeaderEndpoint extends AbstractJDomPayloadEndpoint {
    XPath respMgrExpression;

    public IncidentHeaderEndpoint() {
        Namespace namespace = Namespace.getNamespace("trust-service", "http://act-informatics.co.uk/trust-service/schemas");
        try {
            respMgrExpression = XPath.newInstance("//trust-service:StartDate");
            respMgrExpression.addNamespace(namespace);
        } catch (JDOMException e) {
            e.printStackTrace();
        }
    }
    protected Element invokeInternal(Element request) throws Exception {
        String respMgr = respMgrExpression.valueOf(request);
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我在tomcat中部署时,我收到以下警告:

14-Oct-2010 13:08:43 org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider addMessages
WARNING: No messages were created, make sure the referenced schema(s) contain elements
14-Oct-2010 13:08:43 org.springframework.ws.wsdl.wsdl11.provider.AbstractPortTypesProvider createOperations
WARNING: No operations were created, make …
Run Code Online (Sandbox Code Playgroud)

java spring wsdl web-services spring-ws

4
推荐指数
1
解决办法
7847
查看次数

SoapFaultMappingExceptionResolver永远不会受到常规java异常的攻击

任何人都可以告诉我为什么我不能用我的解析器捕获常规Java异常,所以我可以在回复响应之前对其进行转换?它永远不会被断点击中.如果不可能,我该怎么办?

SoapFaultMappingExceptionResolver

public class LisSoapFaultTranslatorExceptionResolver extends SoapFaultMappingExceptionResolver {

    @Override
    protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) {

        SoapFaultDetail detail = fault.addFaultDetail();
    }
}
Run Code Online (Sandbox Code Playgroud)

<sws:annotation-driven />
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" />
<bean id="exceptionResolver"
            class="com.openclass.adapter.ws.resolvers.LisSoapFaultTranslatorExceptionResolver">
            <property name="defaultFault" value="RECEIVER,Server error">
            </property>
            <property name="exceptionMappings">
                <value>java.lang.Exception=SERVER,FaultMsg</value>
        </property>
    </bean>
Run Code Online (Sandbox Code Playgroud)

有错误的肥皂反应

<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">java.lang.NullPointerException</faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)

网络服务

@PayloadRoot(localPart="readCourseSectionRequest", namespace="http://www.imsglobal.org/services/lis/cmsv1p0/wsdl11/sync/imscms_v1p0")
    @ResponsePayload
    public ReadCourseSectionResponse readCourseSection(@RequestPayload ReadCourseSectionRequest request, MessageContext messageContext) {

            // Throws error since courseService is null
        ReadCourseSectionResponse openClassResponse = courseService.readCourseSection(request);

        return new …
Run Code Online (Sandbox Code Playgroud)

java spring soap spring-ws exception

4
推荐指数
1
解决办法
5510
查看次数