Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <build>
- <finalName>generated-webservices</finalName>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.9</version>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${project.build.directory}/generated/src/main/java</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxws-maven-plugin</artifactId>
- <version>1.12</version>
- <configuration>
- <wsdlUrls>
- <wsdlUrl>http://CMS-Server/webservices/CoreService2011.svc?wsdl</wsdlUrl>
- </wsdlUrls>
- <keep>true</keep>
- <sourceDestDir>${project.build.directory}/target/generated/src/main/java</sourceDestDir>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>wsimport</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <!-- Use current JAX-WS RI version -->
- <dependency>
- <groupId>com.sun.xml.ws</groupId>
- <artifactId>jaxws-tools</artifactId>
- <version>2.1.7</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.ws</groupId>
- <artifactId>jaxws-rt</artifactId>
- <version>2.1.7</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>xmlbeans-maven-plugin</artifactId>
- <version>2.3.3</version>
- <executions>
- <execution>
- <goals>
- <goal>xmlbeans</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
- <xmlConfigs>
- <xmlConfig implementation="java.io.File">${basedir}/src/main/resources/config/xmlbeans.xsdconfig</xmlConfig>
- </xmlConfigs>
- <sourceGenerationDirectory>${project.build.directory}/generated-sources</sourceGenerationDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
- public class BasicHttpAuthenticator extends Authenticator {
- private final String user;
- private final String password;
- public BasicHttpAuthenticator(String user, String password) {
- this.user = user;
- this.password = password;
- }
- @Override
- protected PasswordAuthentication getPasswordAuthentication(){
- return new PasswordAuthentication(user, password.toCharArray());
- }
- }
- private static final QName Q_NAME = new QName("http://www.sdltridion.com/ContentManager/CoreService","CoreService2011");
- public String connectCoreService() throws Exception {
- BasicHttpAuthenticator basicHttpAuthenticator = new BasicHttpAuthenticator(username, password);
- Authenticator.setDefault(basicHttpAuthenticator);
- URL url = new URL(wsdl);
- CoreService2011 service = new CoreService2011(url,Q_NAME);
- ICoreService endpoint = service.getBasicHttp();
- UserData currentUser = endpoint.getCurrentUser();
- System.out.println(String.format("'%s' %s", currentUser.getTitle(), currentUser.getId()));
- return "core service connected";
- }
- endpoint.getCurrentUser();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement