A Java library for interacting with SharePoint list data via the legacy SOAP (Lists.asmx) web service. It supports SharePoint Online (Office 365) out of the box and can be configured for on-premises SharePoint deployments by supplying a custom protocol, STS URL, or skipping cookie-based authentication entirely.
- Requirements
- Project Structure
- Quick Start — Linux / macOS
- Quick Start — Windows 11
- Building the Project
- Running the Tests
- Using the Connector in Your Code
- Authentication: SAML Template
- Troubleshooting
| Tool | Minimum version | Notes |
|---|---|---|
| JDK | 17 (LTS) | Java 21 (LTS) also works. OpenJDK or any compatible distribution (Temurin, Zulu, Corretto, …). Must include wsimport — see note below. |
| Maven | 3.9 | Tested with Apache Maven 3.9.x |
| wsimport | bundled with JDK 8 | Required only at build time. See wsimport note below. |
| Internet access (build) | — | Maven downloads dependencies from Maven Central on first build. |
| SharePoint tenant | — | Required only at runtime for live calls. Tests run fully offline. Supports SharePoint Online and on-premises deployments. |
wsimport was removed from JDK 9+.
The build locates it via the system PATH. Install a JDK 8 alongside your JDK 17 to provide it:
- Linux (apt):
sudo apt-get install temurin-8-jdkand the tool is at
/usr/lib/jvm/temurin-8-jdk-amd64/bin/wsimport. Add that directory to yourPATHbefore the JDK 17bindirectory. - macOS (Homebrew):
brew install --cask temurin@8installs it at
/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/bin/wsimport. Add that toPATH. - Windows 11: download Temurin 8 from adoptium.net and add its
binfolder to the front ofPATH(see Windows section for full steps).
Java365/
├── connector/ # Main source package (package connector)
│ ├── _Constants.java # Shared URLs and charset constants
│ ├── SharePointClient.java# Claims-based (SAML) authentication
│ ├── Manager.java # List operations: read, insert, attach files
│ └── ListsRequest.java # CAML XML batch request builder
├── wsdl/
│ └── wsdlfile.wsdl # SharePoint Lists web service WSDL
├── src/
│ └── test/java/connector/ # JUnit 5 test classes
│ ├── ConstantsTest.java
│ ├── ListsRequestTest.java
│ ├── ManagerXmlTest.java
│ └── ManagerAuthTest.java
├── pom.xml # Maven build descriptor
└── .gitignore
Important: The
connector/directory sits at the repository root, not undersrc/main/java. This is the original project layout and is preserved intentionally. Maven is configured with<sourceDirectory>${project.basedir}</sourceDirectory>to handle it.
Debian / Ubuntu:
sudo apt-get update
sudo apt-get install -y temurin-17-jdk # Eclipse Adoptium
java -version # should print openjdk 17...macOS (Homebrew):
brew install --cask temurin@17
java -versionDebian / Ubuntu:
sudo apt-get install -y temurin-8-jdkmacOS (Homebrew):
brew install --cask temurin@8Make sure wsimport resolves but java / javac still point to JDK 17:
Debian / Ubuntu — add to ~/.bashrc (or ~/.zshrc):
export PATH="/usr/lib/jvm/temurin-8-jdk-amd64/bin:$PATH"
export JAVA_HOME="/usr/lib/jvm/temurin-17-jdk-amd64"Then reload: source ~/.bashrc
macOS — add to ~/.zshrc:
export PATH="/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/bin:$PATH"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home"Then reload: source ~/.zshrc
Verify:
java -version # should show 17
wsimport -version # should show wsimport version "2.x.x"Debian / Ubuntu:
sudo apt-get install -y maven
mvn -versionmacOS (Homebrew):
brew install maven
mvn -versiongit clone https://github.com/crsuarez/Java365.git
cd Java365
mvn package -DskipTests # compile + package (skip tests for speed)mvn testExpected output:
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0 -- ManagerXmlTest
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0 -- ConstantsTest
[INFO] Tests run: 14, Failures: 0, Errors: 0, Skipped: 0 -- ListsRequestTest
[INFO] Tests run: 21, Failures: 0, Errors: 0, Skipped: 0 -- ManagerAuthTest
[INFO] Tests run: 56, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
- Go to adoptium.net and download the Windows x64
.msiinstaller for Temurin 17. - Run the installer. Choose "Add to PATH" and "Set JAVA_HOME" during setup.
- Open a new Command Prompt or PowerShell and verify:
java -version
- Go to adoptium.net and download the Windows x64
.msifor Temurin 8. - Run the installer. Do not let it override
JAVA_HOMEor overwrite the existingPATHentry for JDK 17 — only install the files. - After installation, note the JDK 8
bindirectory. It is typically:C:\Program Files\Eclipse Adoptium\jdk-8.0.xxx-hotspot\bin
Open System Properties → Environment Variables (or use PowerShell):
# In an elevated PowerShell window:
$jdk8bin = "C:\Program Files\Eclipse Adoptium\jdk-8.0.xxx-hotspot\bin"
[System.Environment]::SetEnvironmentVariable(
"PATH",
"$jdk8bin;" + [System.Environment]::GetEnvironmentVariable("PATH", "Machine"),
"Machine"
)Replace jdk-8.0.xxx-hotspot with the exact directory name installed on your machine.
Open a new Command Prompt and verify:
java -version # should show 17
wsimport -version # should show wsimport version "2.x.x"Important:
wsimportmust appear first inPATH. Ifjava -versionnow shows 8, move the JDK 17binentry back to the top ofPATH.
- Download the latest Binary zip archive from maven.apache.org/download (e.g.
apache-maven-3.9.x-bin.zip). - Extract to a directory such as
C:\tools\apache-maven-3.9.x. - Add
C:\tools\apache-maven-3.9.x\bintoPATH(same Environment Variables dialog). - In a new Command Prompt:
mvn -version
git clone https://github.com/crsuarez/Java365.git
cd Java365
mvn package -DskipTestsmvn testThe build performs the following steps automatically in order:
initialize— Creates thetarget/generated-sources/wsimportoutput directory.generate-sources— Runswsimportagainstwsdl/wsdlfile.wsdlto generate the SharePoint SOAP client stubs intotarget/generated-sources/wsimport/com/microsoft/schemas/sharepoint/soap/.compile— Compiles the generated stubs together with theconnector/source files.test-compile— Compiles the test classes undersrc/test/java/.test— Runs all JUnit 5 tests via Maven Surefire.
| Command | What it does |
|---|---|
mvn compile |
Generate stubs + compile sources only |
mvn test |
Compile + run all 51 unit tests |
mvn package -DskipTests |
Compile + package JAR without running tests |
mvn clean test |
Full clean rebuild + tests |
mvn test -pl . -Dtest=ManagerXmlTest |
Run a single test class |
The compiled JAR is placed at target/java365-1.0-SNAPSHOT.jar.
All tests are fully offline — they do not require a SharePoint tenant or any network connection.
# Run all tests
mvn test
# Run a specific test class
mvn test -Dtest=ListsRequestTest
# Run a specific test method
mvn test -Dtest=ManagerXmlTest#generateXmlNodeBlocksXxeDoctypeDeclaration
# Run tests with verbose output
mvn test -Dsurefire.useFile=false| Test class | # tests | What it covers |
|---|---|---|
ConstantsTest |
10 | Every constant in _Constants |
ListsRequestTest |
14 | CAML batch XML structure, all three request types, createListItem field generation and error paths |
ManagerXmlTest |
11 | generateXmlNode() XML parsing, XXE/DOCTYPE attack blocking, xmlToString() output format |
ManagerAuthTest |
21 | sharePointListsAuth preconditions, null-safety guards, mocked SOAP port delegation; protocol overload and null/empty cookie-token handling for on-premises scenarios |
| Total | 56 |
// Initialise the endpoint (called once per session, before any other Manager calls)
Manager.createManagerService("yoursite.sharepoint.com", "/sites/your-site");
// Obtain a cookie token via claims-based (SAML) authentication
SharePointClient client = new SharePointClient(
"[email protected]",
"YourPassword",
"yoursite.sharepoint.com");
// Build an authenticated SOAP port
ListsSoap port = Manager.sharePointListsAuth(
"[email protected]",
"YourPassword",
client.getCookieNedToken());For on-premises deployments use the overloaded constructors that accept an explicit protocol and/or a custom STS URL.
// Pass the protocol explicitly — on-prem sites often run over plain HTTP
Manager.createManagerService("http://", "intranet.corp.local", "/sites/your-site");// Supply your ADFS / custom STS endpoint instead of the Microsoft Online default
SharePointClient client = new SharePointClient(
"DOMAIN\\user",
"YourPassword",
"intranet.corp.local",
"https://adfs.corp.local/adfs/services/trust/13/usernamemixed");On-premises SharePoint often relies on NTLM or Basic authentication instead of
cookie-based claims. Pass null as the cookieToken; the connector will omit the
Cookie header and rely solely on the username and password set on the SOAP binding.
Manager.createManagerService("http://", "intranet.corp.local", "/sites/your-site");
ListsSoap port = Manager.sharePointListsAuth("DOMAIN\\user", "YourPassword", null);ArrayList<String> columns = new ArrayList<>(List.of("Title", "Description", "Created"));
Manager.displaySharePointList(port, "My List Name", columns, "100");HashMap<String, String> fields = new HashMap<>();
fields.put("Title", "New item title");
fields.put("Body", "Item content goes here");
Manager.insertListItem(port, "My List Name", fields);// Attach a local file to the last inserted item
Manager.addItemWithAttachmentToList(
port,
"My List Name",
fields,
"/path/to/document.pdf",
"document.pdf");SharePointClient reads a SAML XML template at startup from:
<project-root>/src/META-INF/SAML.xml
This file is not included in the repository because it contains your tenant-specific SAML envelope. Create it at that path with the following structure, replacing the [...] placeholders (the code substitutes them at runtime):
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing"
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action>...</a:Action>
<a:ReplyTo><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>
<a:To>[endpoint]</a:To>
<o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken>
<o:Username>[username]</o:Username>
<o:Password>[password]</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
...
</s:Body>
</s:Envelope>The [username], [password], and [endpoint] tokens are replaced with the values passed to the SharePointClient constructor.
Security note: Never commit
SAML.xml(or any file containing credentials) to version control. Add it to.gitignore.
wsimport was removed from JDK 9+. Install JDK 8 and add its bin directory to the front of your PATH. See wsimport note.
Run mvn initialize once to create the directory, then retry mvn test. This should not occur in normal usage.
This means the JAX-WS RI dependency (com.sun.xml.ws:rt) was not resolved. Check your internet connection and run mvn dependency:resolve to download it from Maven Central.
The SAML template file is missing. Create src/META-INF/SAML.xml as described in Authentication: SAML Template.
SharePoint did not return FedAuth and rtFa cookies. This usually means:
- Wrong username or password.
- The SAML XML template is malformed or incomplete.
- Multi-factor authentication is enforced on the account (app passwords or a service account may be required).
Ensure the terminal and the JVM use UTF-8. Add -Dfile.encoding=UTF-8 to the Maven command:
mvn test -Dfile.encoding=UTF-8