Created
August 13, 2008 18:43
-
-
Save atifaziz/5284 to your computer and use it in GitHub Desktop.
Jayrock JS proxy tool
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
# | |
# 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