Skip to content

Commit 9475ba2

Browse files
committed
Merge pull request #8 from cloudsoft/winrm-jax-ws
Pure Java WinRM client
2 parents 468daac + 3ac04fb commit 9475ba2

File tree

95 files changed

+3037
-7311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3037
-7311
lines changed

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

PKG-INFO

Lines changed: 0 additions & 24 deletions
This file was deleted.

client/pom.xml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
<parent>
24+
<groupId>io.cloudsoft.windows</groupId>
25+
<artifactId>winrm4j-parent</artifactId>
26+
<version>0.2.0-SNAPSHOT</version>
27+
</parent>
28+
<artifactId>winrmj4-client</artifactId>
29+
<name>WinRM Client</name>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>io.cloudsoft.windows</groupId>
34+
<artifactId>winrm4j-service</artifactId>
35+
<version>${project.version}</version>
36+
<scope>provided</scope>
37+
</dependency>
38+
</dependencies>
39+
40+
<build>
41+
<plugins>
42+
<!-- Needed so eclipse can see the generated sources -->
43+
<plugin>
44+
<groupId>org.codehaus.mojo</groupId>
45+
<artifactId>build-helper-maven-plugin</artifactId>
46+
<executions>
47+
<execution>
48+
<id>add-source</id>
49+
<phase>generate-sources</phase>
50+
<goals>
51+
<goal>add-source</goal>
52+
</goals>
53+
<configuration>
54+
<sources>
55+
<source>${project.build.directory}/generated-sources/wsimport/</source>
56+
</sources>
57+
</configuration>
58+
</execution>
59+
<execution>
60+
<id>add-resource</id>
61+
<phase>generate-resources</phase>
62+
<goals>
63+
<goal>add-resource</goal>
64+
</goals>
65+
<configuration>
66+
<resources>
67+
<resource>
68+
<directory>${project.build.directory}/winrm4j-service-wsdl</directory>
69+
</resource>
70+
</resources>
71+
</configuration>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-dependency-plugin</artifactId>
78+
<executions>
79+
<execution>
80+
<id>unpack</id>
81+
<phase>generate-sources</phase>
82+
<goals>
83+
<goal>unpack</goal>
84+
</goals>
85+
<configuration>
86+
<artifactItems>
87+
<artifactItem>
88+
<groupId>io.cloudsoft.windows</groupId>
89+
<artifactId>winrm4j-service</artifactId>
90+
<version>${project.version}</version>
91+
<outputDirectory>${project.build.directory}/winrm4j-service-wsdl</outputDirectory>
92+
<includes>META-INF/wsdl/**</includes>
93+
</artifactItem>
94+
</artifactItems>
95+
</configuration>
96+
</execution>
97+
</executions>
98+
</plugin>
99+
<plugin>
100+
<groupId>org.jvnet.jax-ws-commons</groupId>
101+
<artifactId>jaxws-maven-plugin</artifactId>
102+
<executions>
103+
<execution>
104+
<id>import-wsdl</id>
105+
<goals>
106+
<goal>wsimport</goal>
107+
</goals>
108+
<configuration>
109+
<extension>true</extension>
110+
<keep>true</keep>
111+
<xnocompile>true</xnocompile>
112+
<bindingFiles>
113+
<bindingFile>bindings.xml</bindingFile>
114+
</bindingFiles>
115+
<wsdlDirectory>${project.build.directory}/winrm4j-service-wsdl/META-INF/wsdl</wsdlDirectory>
116+
<args>
117+
<arg>-clientjar</arg>
118+
<arg>wsdl.jar</arg>
119+
</args>
120+
</configuration>
121+
</execution>
122+
</executions>
123+
</plugin>
124+
</plugins>
125+
<pluginManagement>
126+
<plugins>
127+
<!--This plugin's configuration is used to store Eclipse m2e settings
128+
only. It has no influence on the Maven build itself. -->
129+
<plugin>
130+
<groupId>org.eclipse.m2e</groupId>
131+
<artifactId>lifecycle-mapping</artifactId>
132+
<version>1.0.0</version>
133+
<configuration>
134+
<lifecycleMappingMetadata>
135+
<pluginExecutions>
136+
<pluginExecution>
137+
<pluginExecutionFilter>
138+
<groupId>org.jvnet.jax-ws-commons</groupId>
139+
<artifactId>jaxws-maven-plugin</artifactId>
140+
<versionRange>[2.3,)</versionRange>
141+
<goals>
142+
<goal>wsimport</goal>
143+
</goals>
144+
</pluginExecutionFilter>
145+
<action>
146+
<ignore></ignore>
147+
</action>
148+
</pluginExecution>
149+
</pluginExecutions>
150+
</lifecycleMappingMetadata>
151+
</configuration>
152+
</plugin>
153+
</plugins>
154+
</pluginManagement>
155+
</build>
156+
</project>

client/src/jaxws/bindings.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
3+
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
4+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
5+
version="2.0">
6+
7+
<jaxws:package name="io.cloudsoft.winrm4j.client" />
8+
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
9+
<jaxws:enableAsyncMapping>false</jaxws:enableAsyncMapping>
10+
11+
<jaxws:bindings
12+
node="//wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://schemas.microsoft.com/wbem/wsman/1/windows/shell']">
13+
<jaxb:schemaBindings>
14+
<jaxb:package name="io.cloudsoft.winrm4j.client.shell" />
15+
</jaxb:schemaBindings>
16+
</jaxws:bindings>
17+
<jaxws:bindings
18+
node="//wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd']">
19+
<jaxb:schemaBindings>
20+
<jaxb:package name="io.cloudsoft.winrm4j.client.wsman" />
21+
</jaxb:schemaBindings>
22+
</jaxws:bindings>
23+
<jaxws:bindings
24+
node="//wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://schemas.xmlsoap.org/ws/2004/09/transfer']">
25+
<jaxb:schemaBindings>
26+
<jaxb:package name="io.cloudsoft.winrm4j.client.transfer" />
27+
</jaxb:schemaBindings>
28+
</jaxws:bindings>
29+
30+
</jaxws:bindings>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.cloudsoft.winrm4j.client;
2+
3+
import java.io.OutputStreamWriter;
4+
import java.io.PrintWriter;
5+
6+
public class CliClient {
7+
8+
public static void main(String[] args) throws Exception{
9+
// System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
10+
// System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
11+
// System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
12+
// System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
13+
// System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold", Integer.toString(Integer.MAX_VALUE));
14+
15+
if (args.length != 4) {
16+
System.out.println("Usage: CliClient <endpoing> <username> <password> <command>");
17+
}
18+
19+
String endpoint = args[0];
20+
String username = args[1];
21+
String password = args[2];
22+
String cmd = args[3];
23+
24+
WinRmClient client = WinRmClient.builder(endpoint)
25+
.credentials(username, password)
26+
.workingDirectory("C:\\")
27+
// .environment(env)
28+
.build();
29+
30+
try {
31+
client.command(cmd, new PrintWriter(new OutputStreamWriter(System.out)), new PrintWriter(new OutputStreamWriter(System.err)));
32+
} finally {
33+
client.disconnect();
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)