Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. <build>
  2. <finalName>generated-webservices</finalName>
  3. <plugins>
  4. <plugin>
  5. <groupId>org.codehaus.mojo</groupId>
  6. <artifactId>build-helper-maven-plugin</artifactId>
  7. <version>1.9</version>
  8. <executions>
  9. <execution>
  10. <id>add-source</id>
  11. <phase>generate-sources</phase>
  12. <goals>
  13. <goal>add-source</goal>
  14. </goals>
  15. <configuration>
  16. <sources>
  17. <source>${project.build.directory}/generated/src/main/java</source>
  18. </sources>
  19. </configuration>
  20. </execution>
  21. </executions>
  22. </plugin>
  23. <plugin>
  24. <groupId>org.codehaus.mojo</groupId>
  25. <artifactId>jaxws-maven-plugin</artifactId>
  26. <version>1.12</version>
  27. <configuration>
  28. <wsdlUrls>
  29. <wsdlUrl>http://CMS-Server/webservices/CoreService2011.svc?wsdl</wsdlUrl>
  30. </wsdlUrls>
  31. <keep>true</keep>
  32. <sourceDestDir>${project.build.directory}/target/generated/src/main/java</sourceDestDir>
  33. </configuration>
  34. <executions>
  35. <execution>
  36. <goals>
  37. <goal>wsimport</goal>
  38. </goals>
  39. </execution>
  40. </executions>
  41. <dependencies>
  42. <!-- Use current JAX-WS RI version -->
  43. <dependency>
  44. <groupId>com.sun.xml.ws</groupId>
  45. <artifactId>jaxws-tools</artifactId>
  46. <version>2.1.7</version>
  47. </dependency>
  48. <dependency>
  49. <groupId>com.sun.xml.ws</groupId>
  50. <artifactId>jaxws-rt</artifactId>
  51. <version>2.1.7</version>
  52. </dependency>
  53. </dependencies>
  54. </plugin>
  55. <plugin>
  56. <groupId>org.codehaus.mojo</groupId>
  57. <artifactId>xmlbeans-maven-plugin</artifactId>
  58. <version>2.3.3</version>
  59. <executions>
  60. <execution>
  61. <goals>
  62. <goal>xmlbeans</goal>
  63. </goals>
  64. </execution>
  65. </executions>
  66. <configuration>
  67. <schemaDirectory>src/main/resources/wsdl</schemaDirectory>
  68. <xmlConfigs>
  69. <xmlConfig implementation="java.io.File">${basedir}/src/main/resources/config/xmlbeans.xsdconfig</xmlConfig>
  70. </xmlConfigs>
  71. <sourceGenerationDirectory>${project.build.directory}/generated-sources</sourceGenerationDirectory>
  72. </configuration>
  73. </plugin>
  74. </plugins>
  75. </build>
  76.  
  77. public class BasicHttpAuthenticator extends Authenticator {
  78.  
  79. private final String user;
  80. private final String password;
  81.  
  82. public BasicHttpAuthenticator(String user, String password) {
  83. this.user = user;
  84. this.password = password;
  85. }
  86.  
  87. @Override
  88. protected PasswordAuthentication getPasswordAuthentication(){
  89. return new PasswordAuthentication(user, password.toCharArray());
  90. }
  91. }
  92.  
  93. private static final QName Q_NAME = new QName("http://www.sdltridion.com/ContentManager/CoreService","CoreService2011");
  94.  
  95. public String connectCoreService() throws Exception {
  96. BasicHttpAuthenticator basicHttpAuthenticator = new BasicHttpAuthenticator(username, password);
  97. Authenticator.setDefault(basicHttpAuthenticator);
  98. URL url = new URL(wsdl);
  99. CoreService2011 service = new CoreService2011(url,Q_NAME);
  100. ICoreService endpoint = service.getBasicHttp();
  101. UserData currentUser = endpoint.getCurrentUser();
  102. System.out.println(String.format("'%s' %s", currentUser.getTitle(), currentUser.getId()));
  103. return "core service connected";
  104. }
  105.  
  106. endpoint.getCurrentUser();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement