Code Monkey home page Code Monkey logo

spring-ws-samples's Introduction

Spring Web Services Samples

Spring Web Services is a product of the Spring community focused on creating document-driven, contract-first Web services. This repository contains sample projects illustrating usage of Spring Web Services.

Spring Boot 3.0 + Spring WS 4.0

This version of the samples focuses on Spring WS 4.0, the generation provided by Spring Boot 3.0. For Spring WS 3.1 (Spring Boot 2.7) samples, check out https://github.com/spring-projects/spring-ws-samples/tree/1.0.x.

Sample Applications

The following sample applications demonstrate the capabilities of Spring Web Services. See the README within each sample project for more information and additional instructions.

  • airline - a complete airline sample that shows both Web Service and O/X Mapping functionality in a complete application

  • echo - a simple sample that shows a bare-bones Echo service

  • mtom - shows how to use MTOM and JAXB2 marshalling

  • stockquote - shows how to use WS-Addressing and the Java 6 HTTP Server

  • tutorial - contains the code from the Spring-WS tutorial

  • weather - shows how to connect to a public SOAP service

Running the Server

Most of the sample apps can be built and run using the following commands from within the server folder.

$ ./mvnw spring-boot:run

Or alternatively, run the following to create runnable JAR file that will run anywhere there’s a JDK:

$ ./mvnw package

Running the Client(s)

Most of the sample apps have a separate client directory containing clients that connect to the server. You can run these clients by using the following command from within each of client subdirectories:

$ ./mvnw spring-boot:run

License

Spring Web Services is released under version 2.0 of the Apache License.

spring-ws-samples's People

Contributors

gregturn avatar poutsma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-ws-samples's Issues

Content-Type needs to be Multipart/Related and with "type=text/xml" or "type=application/soap+xml"

I am getting the following exception when trying to use MTOM in my web service client:

Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Content-Type needs to be Multipart/Related and with "type=text/xml" or "type=application/soap+xml"
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.identifyContentType(MessageImpl.java:629)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.(MessageImpl.java:301)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl.(Message1_1Impl.java:65)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:63)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:190)
... 86 common frames omitted

The message looks like this:

[13.08.2020 10:32:02.320][https-jsse-nio-9998-exec-6 ][DEBUG][WebServiceAccessor.createConnection:111 ] Opening [org.springframework.ws.transport.http.HttpComponentsConnection@767912eb] to [http://localhost:9080/soap/services/FormsService?blob=mtom]
[13.08.2020 10:32:02.397][https-jsse-nio-9998-exec-6 ][TRACE][WebServiceTemplate.sendRequest:653 ] Sent request [------=_Part_0_1137162597.1597307522369
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">...</SOAP-ENV:Envelope>
------=_Part_0_1137162597.1597307522369
Content-Type: application/octet-stream
Content-ID: [email protected]
Content-Transfer-Encoding: binary

<pst:Data xmlns:pst="http://ac.adobe.com/PSTDataSchema" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ac.adobe.com/PSTDataSchema PSTDataSchema.xsd">...</pst:Data>
------=_Part_0_1137162597.1597307522369--]
[13.08.2020 10:32:04.208][https-jsse-nio-9998-exec-6 ][ERROR][MessageImpl.identifyContentType:628 ] SAAJ0536: Content-Type needs to be Multipart/Related and with type=text/xml or application/soap+xml

I am using the following JRE:

openjdk version "1.8.0_222"
OpenJDK Runtime Environment (Zulu 8.40.0.25-CA-win64) (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (Zulu 8.40.0.25-CA-win64) (build 25.222-b10, mixed mode)

MTOM Streaming

How to configure Spring for MTOM streaming in this example?

Error with in MTOM server

Hello,

I can run the MTOM server, but when i launch MTOM client (both SpringWS and JAX-WS) i have an error in Server console.

Server log in attachment.

But in short :
xsd 'class path resource [schema.xsd]' does not exist

I suppose it come from the class MtomServerConfiguration.java

@Bean public SimpleXsdSchema schema() { return new SimpleXsdSchema(new ClassPathResource("/schema.xsd")); }

springWS-error.txt

Solved Airline Sample pom.xml error thown by com.sun.tools systemPath

Thank you for providing such a good sample while studying web services.

While checking the code operation or internal operation by cloning the project,
I am writing this issue to the level of sharing in case an error occurred and could help those who experienced the error like me.

The environment of my development machine is as follows.

  • Development Environment
title detail
OS Version Mac BigSur 11.4
IDE Version Intelij ultimate 2021.3.1
Java Version Adopt-OpenJdk-1.8
  • Error Message
[ERROR]     'build.plugins.plugin[org.apache.maven.plugins:maven-antrun-plugin].dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${env.JAVA_HOME}/lib/tools.jar @ line 56, column 19

When I checked based on the above error message, I suspected that an error occurred in the pom.xml section below.

  • airline/client/jax-ws/pom.xml
<dependency>
  <groupId>com.sun</groupId>
  <artifactId>tools</artifactId>
  <version>1.5.0</version>
  <scope>system</scope>
  <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>

I solved this pom.xml by modifying it as follows.

<dependency>
   ... same above pom.xml ...
   <systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>

Interceptors not intercepting when endpoint not found

Hello,

I am not sure if this is an issue, maybe I am misunderstanding how things should work.

But, to the problem. In MessageDispatcher.class on line 237 there is a catch block where a comment states that if there are no endpoints found there is no triggering of interceptors, as is seen in code below.

catch (NoEndpointFoundException ex) {
    // No triggering of interceptors if no endpoint is found
    if (endpointNotFoundLogger.isWarnEnabled()) {
        endpointNotFoundLogger.warn("No endpoint mapping found for [" + messageContext.getRequest() + "]");
    }
    throw ex;
}

What I am wondering is how should I then handle an incoming SOAP message that is empty? Basically there is a need for me to recognise this empty message and return the almost the same message.

The actual message looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body/>
</soapenv:Envelope>

In WSDL file there is something like this:

<message name="PingRequest"/>

<message name="PingResponse"/>

with this basically the service provider wants to have a way to check if my service, for consuming the their SOAP messages, is alive.

Now I am not sure if this is an issue for here, because I would like to be able to get even an empty SOAP message and act upon it, so why are the interceptors not being allowed to intercept also these messages?

For more information there is also a stackoverflow post, for reference, I don't expect this to be a question board.

So, just wondering if this is really an issue or you intend this to work only in this way?

Thank you,
Dusko

native compile problem

I use "mvn -Pnative clean native:compile" compiled the mtm project ,when i run the appliction,when i get the wsdl file it throw the error "java.lang.ClassNotFoundException: org.springframework.ws.soap.saaj.SaajSoapMessageFactory" but jar package does not have the problem;
image
image

schema.xsd in the wrong position for the mtom server example

In the mtom server project example either the schema.xsd is in the wrong place, or the build.gradle file expects it to be in the wrong place.

The build.gradle expects it in /src/main/webapp/WEB-INF/, but the file actually is in /src/main/resources/.

Sample for swaref ??

Question :

I don't find any sample code showing the handle of attachment via swaref (write/read)... Any idea where to find this ?

Thx

Build fails with an exception

When I issue the command ".gradle build" from the /spring-ws-samples/airline directory using gradle version 2.8 I obtain the following exception:

FAILURE: Build failed with an exception.

*Where:
Build file '..../spring-ws-samples/airline/server/build.gradle' line: 64

*What went wrong:
Execution failed for task ':server:enhance'.

Could not find property 'runtimeClasspath' on project: ':server';

Line 64 of the file contains:

}

task enhance {
doLast {
ant.taskdef( name : 'openjpaenhancer',
classpath : project.runtimeClasspath.asPath,
classname : 'org.apache.openjpa.ant.PCEnhancerTask'
)

ant.openjpaenhancer(
    classpath : project.runtimeClasspath.asPath)
    ant.fileset(dir: "${projectDir}/src/main/java/") {
        include(name: '**/domain/*.java')
        exclude(name: 'ServiceClass.java')
    }
}   

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.