用于调用或调用其余Web服务的maven插件

pav*_*van 6 plugins maven

是否有任何maven插件将调用已经存在的其他Web服务?或者有没有办法在pom.xml中调用Web服务.就像我们调用外部命令org.codehaus.mojo exec-maven-plugin 1.2请帮助我

Mar*_*nor 7

如果需要使用POST方法调用REST服务,则可以使用groovy脚本

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.myspotontheweb.demo</groupId>
    <artifactId>maven-rest</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.groovy.modules.http-builder</groupId>
            <artifactId>http-builder</artifactId>
            <version>0.5.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.groovy.maven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>execute</goal>
                      </goals>
                       <configuration>
                          <source>
                            import groovyx.net.http.RESTClient
                            import groovy.util.slurpersupport.GPathResult
                            import static groovyx.net.http.ContentType.XML

                            solr = new RESTClient('http://localhost:8080/solr/update')

                            def response = solr.post(
                                contentType: XML,
                                requestContentType: XML,
                                body: {
                                    add {
                                        doc {
                                            field(name:"id", "SOLR1000")
                                            field(name:"name", "Solr, the Enterprise Search Server")
                                            field(name:"manu", "Apache Software Foundation")
                                            field(name:"cat", "software")
                                            field(name:"cat", "search")
                                            field(name:"features", "Advanced Full-Text Search Capabilities using Lucene")
                                            field(name:"features", "Optimized for High Volume Web Traffic")
                                            field(name:"features", "Standards Based Open Interfaces - XML and HTTP")
                                            field(name:"features", "Comprehensive HTML Administration Interfaces")
                                            field(name:"features", "Scalability - Efficient Replication to other Solr Search Servers")
                                            field(name:"features", "Flexible and Adaptable with XML configuration and Schema")
                                            field(name:"features", "Good unicode support: héllo (hello with an accent over the e)")
                                            field(name:"price", "0")
                                            field(name:"popularity", "10")
                                            field(name:"inStock", "true")
                                            field(name:"incubationdate_dt", "2006-01-17T00:00:00.000Z")
                                        }
                                    }
                                }
                            )
                            log.info "Solr response status: ${response.status}"
                         </source>
                     </configuration>
                 </execution>
              </executions>
         </plugin>
    </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

REST API例如由休伯特·克莱恩Ikkink的博客采取:

http://mrhaki.blogspot.com/