Created
August 26, 2011 11:29
-
-
Save simonharrer/1173228 to your computer and use it in GitHub Desktop.
Use JRuby to create a Java Soap Web Service
This file contains 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
require 'java' | |
require 'jruby/core_ext' | |
module WS | |
class WebService | |
def test() | |
puts "Call received at #{Time.new}" | |
# x = Result.new | |
# x.name = "asdf" | |
# return x | |
"muh" | |
end | |
end | |
class Result | |
attr_accessor :name | |
end | |
# make them accessible for jax-ws | |
Result.become_java! | |
WebService.add_class_annotation(javax.jws.WebService => { "targetNamespace" => "http://test.net/muh/"}) | |
WebService.add_method_signature("test", [java.lang.String]) | |
WebService.become_java! | |
end | |
Endpoint = javax.xml.ws.Endpoint | |
Endpoint.publish( "http://localhost:8888/WebServiceService/WebServicePort", WS::WebService.new ) |
@nurettin
add_class_annotation renamed to add_class_annotations
If I want test() to return an instance of Result, how do I have to change WebService.add_method_signature?
Trying something like [Result.java_class] I get the error:
ClassLoader.java:522:in `findClass': java.lang.ClassNotFoundException: rubyobj.WS.Result
@shtirlic @veberie I have the same question. I tried the same, but got an javax.xml.ws.WebServiceException: Unable to create JAXBContext
exception.
Any ideas?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NoMethodError: undefined method `add_class_annotation' (jruby-1.7.2)