Last active
March 9, 2017 06:16
-
-
Save takawitter/1c7384ff8837f2321b5d60ece4671e92 to your computer and use it in GitHub Desktop.
SOAP Service and Client using language grid libraries and Groovy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.eclipse.jetty:jetty-webapp:9.4.0.v20161208') | |
@Grab('org.langrid:jp.go.nict.langrid.service.language_1_2:1.0.10') | |
@Grab('org.langrid:jp.go.nict.langrid.servicecontainer.handler.axis:1.0.10') | |
import jp.go.nict.langrid.service_1_2.translation.TranslationService; | |
import jp.go.nict.langrid.servicecontainer.handler.annotation.Service; | |
import jp.go.nict.langrid.servicecontainer.handler.axis.SGAxisServlet; | |
import org.eclipse.jetty.server.Server; | |
import org.eclipse.jetty.webapp.WebAppContext; | |
public class TestServiceImpl implements TranslationService{ | |
public String translate(String sourceLang, String targetLang, String source){ | |
return sourceLang + ":" + targetLang + ":" + source; | |
} | |
} | |
@Service(name="TestService", impl=TestServiceImpl.class, intf=TranslationService.class) | |
public class Servlet extends SGAxisServlet{} | |
WebAppContext webapp = new WebAppContext("./", "/app"); | |
webapp.addServlet(Servlet.class, "/services/*"); | |
Server server = new Server(8080); | |
server.setHandler(webapp); | |
server.start(); | |
server.join(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('org.langrid:jp.go.nict.langrid.client.soap:1.0.10') | |
@Grab('org.langrid:jp.go.nict.langrid.service.language_1_2:1.0.10') | |
@Grab('org.langrid:jp.go.nict.langrid.servicecontainer.handler.axis:1.0.10') | |
import jp.go.nict.langrid.client.soap.SoapClientFactory; | |
import jp.go.nict.langrid.service_1_2.translation.TranslationService; | |
println new SoapClientFactory().create( | |
TranslationService.class, | |
new URL("http://127.0.0.1:8080/app/services/TestService") | |
).translate('en','ja','hello'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment