Spring Web Services是Spring社区的一个产品,专注于创建文档驱动的Web服务。 Spring Web Services旨在促进契约优先的SOAP服务开发,允许使用多种方式之一来操作XML有效负载来创建灵活的Web服务。
找不到 [SaajSoapMessage {http://schemas.xmlsoap.org/soap/envelope/}UpdateXXXRequest] 的端点映射
我升级了一个旧应用程序,它公开了具有不同命名空间的 6 个不同的 SOAP Web 服务。当我们使用通过其生成的 wsdl 获取的端点时,一切似乎都正常工作。 这里...
Spring ws - Swaref 的数据处理程序仍然为空
我使用 Spring boot starter Web 服务来开发带有附件服务的 SOAP。 由于未知原因,附件未解组。使用了 Jaxb Unmarshaller,但属性
无效的内容类型:SOAP 的 application/xml 错误
我有一个基于Spring Boot 1.5的应用程序Spring WS,SAAJ-impl-1.3.28.jar。它适用于内容类型“text/xml”购买,抛出以下 Content-Type:application/xml 异常。 “错误 - 一个......
我需要使用行业标准中的一些 XSD 文件来生成 SOAP Web 服务。 REST 是不可能的,因为使用者只能进行 SOAP 调用。 XSD 中的参数是
spring boot websocket api 404 未找到
在我的 Spring Boot 应用程序中,当我尝试连接到 ws 端点时,我在客户端收到 404 错误。 客户端代码 让 wsUri =“ws://localhost:8080/chat” 让 websocket = new WebSocket(wsU...
升级到 Spring Boot 3.3.5 后,WebSocketMessageBroker 无法按预期工作
我有一个使用以下配置公开 WebSocket 端点的应用程序 @配置 @EnableWebSocketMessageBroker 公共类 WebSocketConfig 实现 WebSocketMessageBrokerConfigurer {
我做了一个简单的网络服务,但是当我尝试在soapui上测试它时,它给出了这个错误: 警告:[10 月 11 日 12:56:38,081] ws.server.EndpointNotFound - 未找到 [SaajSoapMessage {
2.1.4 中没有 org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender
我有一个使用 org.springframework.ws, 2.1.4.RELEASE 的应用程序,现在需要使用 SSL。 我希望注入 org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender ...
UsernameTokenValidator 不能@Autowired Dao
我有一个 Spring-ws,我正在使用 Apahce-wss4j 进行 spring-ws 身份验证。我想在我的自定义 TokenValidator 类中使用我的 Dao 类。但有一个例外不能@Autowired我的Dao类...
我正在尝试将 springboot 2.7.18 升级到 3.3.1,其中包括 Spring WS 4.0.11。 我使用 WebServiceTemplate 我的配置是这样的: 私有 WebServiceTemplate buildWebServiceTemplate(
如何将连接池与 HttpsUrlConnectionMessageSender 结合使用
我正在尝试使用 Spring WS 发出 Soap 请求。该请求需要跨客户端证书发送到服务器。我已经弄清楚了向服务器发出正确请求的配置...
将SoapHeader添加到org.springframework.ws.WebServiceMessage
如何将对象添加到 org.springframework.ws.WebServiceMessage 的肥皂头中 这是我希望最终得到的结构: 如何将对象添加到org.springframework.ws.WebServiceMessage的soap标头中 这是我希望最终得到的结构: <soap:Header> <credentials xmlns="http://example.com/auth"> <username>username</username> <password>password</password> </credentials> </soap:Header> 基本上,您需要在客户端中使用 WebServiceMessageCallback 在消息创建之后、发送之前修改消息。 @skaffman 已经非常准确地描述了其余代码,因此整个内容可能如下所示: public void marshalWithSoapActionHeader(MyObject o) { webServiceTemplate.marshalSendAndReceive(o, new WebServiceMessageCallback() { public void doWithMessage(WebServiceMessage message) { try { SoapMessage soapMessage = (SoapMessage)message; SoapHeader header = soapMessage.getSoapHeader(); StringSource headerSource = new StringSource("<credentials xmlns=\"http://example.com/auth\">\n + <username>"+username+"</username>\n + <password>"+password"+</password>\n + </credentials>"); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(headerSource, header.getResult()); } catch (Exception e) { // exception handling } } }); } 就我个人而言,我发现 Spring-WS 很难满足这样的基本需求,他们应该修复 SWS-479。 您可以执行以下操作: public class SoapRequestHeaderModifier implements WebServiceMessageCallback { private final String userName = "user"; private final String passWd = "passwd"; @Override public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException { if (message instanceof SaajSoapMessage) { SaajSoapMessage soapMessage = (SaajSoapMessage) message; MimeHeaders mimeHeader = soapMessage.getSaajMessage().getMimeHeaders(); mimeHeader.setHeader("Authorization", getB64Auth(userName, passWd)); } } private String getB64Auth(String login, String pass) { String source = login + ":" + pass; String retunVal = "Basic " + Base64.getUrlEncoder().encodeToString(source.getBytes()); return retunVal; } } 然后 Object response = getWebServiceTemplate().marshalSendAndReceive(request, new SoapRequestHeaderModifier()); 您需要将 WebServiceMessage 转换为 SoapMessage,其中有一个 getSoapHeader() 方法可用于修改标题。反过来,SoapHeader有各种添加元素的方法,包括getResult()(可以用作Transformer.transform()操作的输出)。 I tried many options and finally below one worked for me if you have to send soap header with authentication(Provided authentication object created by wsimport) and also need to set soapaction. public Response callWebService(String url, Object request) { Response res = null; log.info("The request object is " + request.toString()); try { res = (Response) getWebServiceTemplate().marshalSendAndReceive(url, request,new WebServiceMessageCallback() { @Override public void doWithMessage(WebServiceMessage message) { try { // get the header from the SOAP message SoapHeader soapHeader = ((SoapMessage) message).getSoapHeader(); // create the header element ObjectFactory factory = new ObjectFactory(); Authentication auth = factory.createAuthentication(); auth.setUser("****"); auth.setPassword("******"); ((SoapMessage) message).setSoapAction( "soapAction"); JAXBElement<Authentication> headers = factory.createAuthentication(auth); // create a marshaller JAXBContext context = JAXBContext.newInstance(Authentication.class); Marshaller marshaller = context.createMarshaller(); // marshal the headers into the specified result marshaller.marshal(headers, soapHeader.getResult()); } catch (Exception e) { log.error("error during marshalling of the SOAP headers", e); } } }); } catch (Exception e) { e.printStackTrace(); } return res; } 您也可以通过创建子元素的键值映射来实现: final Map<String, String> elements = new HashMap<>(); elements.put("username", "username"); elements.put("password", "password"); 在soap标头中设置子元素的命名空间和前缀: final String LOCAL_NAME = "credentials"; final String PREFIX = ""; final String NAMESPACE = "http://example.com/auth"; 然后,您可以调用 WebServiceTemplate 的方法 marshalSendAndReceive,在其中重写 WebServiceMessageCallback 的方法 doWithMessage,如下所示: Object response = getWebServiceTemplate().marshalSendAndReceive(request, (message) -> { if (message instanceof SaajSoapMessage) { SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message; SOAPMessage soapMessage = saajSoapMessage.getSaajMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (Objects.nonNull(elements)) { try { SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPHeader soapHeader = soapEnvelope.getHeader(); Name headerElementName = soapEnvelope.createName( LOCAL_NAME, PREFIX, NAMESPACE ); SOAPHeaderElement soapHeaderElement = soapHeader.addHeaderElement(headerElementName); elements.forEach((key, value) -> { try { SOAPElement element = soapHeaderElement.addChildElement(key, PREFIX); element.addTextNode(value); } catch (SOAPException e) { // error handling } }); soapMessage.saveChanges(); } catch (SOAPException e) { // error handling } } } }); 上述步骤导致: <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <credentials xmlns="http://example.com/auth"> <password>password</password> <username>username</username> </credentials> </env:Header> <env:Body> <!-- your payload --> </env:Body> </env:Envelope> Response response = (Response)getWebServiceTemplate() .marshalSendAndReceive(request, new HeaderModifier()); 创建类 HeaderModifier 并重写 doWithMessage public class HeaderModifier implements WebServiceMessageCallback { private static PrintStream out = System.out; @Override public void doWithMessage(WebServiceMessage message) throws IOException { SaajSoapMessage soapMessage = (SaajSoapMessage) message; SoapEnvelope soapEnvelope = soapMessage.getEnvelope(); SoapHeader soapHeader = soapEnvelope.getHeader(); //Initialize QName for Action and To QName action = new QName("{uri}","Action","{actionname}"); QName to = new QName("{uri}","To","{actionname}"); soapHeader.addNamespaceDeclaration("{actionname}", "{uri}"); SoapHeaderElement soapHeaderElementAction = soapHeader.addHeaderElement(action); SoapHeaderElement soapHeaderElementTo = soapHeader.addHeaderElement(to); soapHeaderElementAction.setText("{text inside the tags}"); soapHeaderElementTo.setText("{text inside the tags}"); soapMessage.setSoapAction("{add soap action uri}"); soapMessage.writeTo(out); } }
超类访问检查失败:类 com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl
我在使用 spring-ws-core.3.1.1 时收到以下错误。除了我们升级了平台并要求我们使用 Java 17(之前的版本是基于 Java 11 构建的)之外,这一切都运行良好。 ...
为什么 SOAP 服务 (jax-ws) 在 Linux 操作系统上在一段时间后停止并抛出 WebServiceTransportException: Unauthorized [401]]?
我开发了一个肥皂应用程序,并向所需的服务发送请求。问题是一段时间后抛出异常: 堆栈跟踪: Servlet.service() 用于 servlet [
Jaxb2Marshaller 与 Spring boot 3+ 和 Jaxb 4 兼容吗?
我正在将我的项目从 Spring Boot 2.7 升级到 Spring Boot 3.1。在这个项目中仍然使用 SOAP,因此我们依赖 Jaxb 和 spring WS。 我正在使用 com.helger.maven 生成 Java 类:
我试图理解有效负载根注释中命名空间的确切含义,即 @PayloadRoot(localPart = "orderRequest", 命名空间 = "http://samples") 我已经拿下了这个
org.springframework.beans.factory.BeanCreationException:创建类中定义的名为“marshaller”的bean时出错
我正在尝试在独立应用程序中使用 spring-ws-2.2.0 和 spring-boot-1.1.8 开发 SOAP Web 服务客户端,但出现此错误: org.springframework.beans.factory.BeanCreationException:错误
spring ws-client 的单元测试 - 检查是否正在调用 marshalSendAndReceive
我的目标是为我的 WebServiceClientImpl 类编写一个单元测试,我想添加一个测试来检查是否正在调用 marshalSendAndReceive。我使用 Mockito 和 powermockito 框架。我需要...
java.lang.NoClassDefFoundError:javax/xml/soap/SOAPException
我已经使用 Spring 创建了一个 Web 服务。在我的嵌入式 tomcat 服务器上运行它时工作正常。但是,当我将其打包为 JAR 文件并使用 java -jar 命令运行它时,我收到了这个
Spring-WS 服务返回错误的内容类型(“text/xml”而不是“application/xop+xml”)
我有一个 Spring-WS Web 服务(SOAP 1.2 MTOM)部署为大型应用程序(在 Weblogic 上)的一部分,返回不正确的内容类型(消费者不喜欢它)。内容类型是 内容类型: