Skip to content

Instantly share code, notes, and snippets.

@atifaziz
Created August 13, 2008 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atifaziz/5284 to your computer and use it in GitHub Desktop.
Save atifaziz/5284 to your computer and use it in GitHub Desktop.
Jayrock JS proxy tool
#
# Usage: jsproxy ASSEMBLY-PATH TYPENAME ( URL )
#
import sys
import clr
clr.AddReferenceToFileAndPath(r'C:\Jayrock\bin\Release\Jayrock.dll')
from sys import stderr
from Jayrock.JsonRpc import *
from Jayrock.JsonRpc.Web import *
from System import Uri, Console, ApplicationException
from System.Reflection import Assembly
def generate_proxy(asm_path, type_name, url):
asm = Assembly.LoadFrom(asm_path)
type = asm.GetType(type_name)
clazz = JsonRpcServices.GetClassFromType(type)
JsonRpcProxyGenerator.Generate(clazz, url, Console.Out)
def main(args):
def dqarg(desc):
if not args:
raise ApplicationException('Missing %s.' % desc)
return args.pop(0)
asm_path = dqarg('assembly path')
type_name = dqarg('type name')
if args:
url = args.pop(0)
else:
url = Uri('http://tempuri.org/')
print >> stderr, ('Warning! Service URL not specified. Using %s for now.' % url)
generate_proxy(asm_path, type_name, url)
if __name__ == '__main__':
try:
main(sys.argv[1:])
except ApplicationException, e:
print >> stderr, e.Message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment