Skip to content

Instantly share code, notes, and snippets.

@simonharrer
Created August 26, 2011 11:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save simonharrer/1173228 to your computer and use it in GitHub Desktop.
Save simonharrer/1173228 to your computer and use it in GitHub Desktop.
Use JRuby to create a Java Soap Web Service
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
Copy link

NoMethodError: undefined method `add_class_annotation' (jruby-1.7.2)

@shtirlic
Copy link

@nurettin
add_class_annotation renamed to add_class_annotations

@veberle
Copy link

veberle commented Apr 18, 2013

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

@jrgns
Copy link

jrgns commented Apr 14, 2015

@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