国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

Microsoft.Net的Java實現(xiàn)

2019-11-18 15:17:13
字體:
來源:轉載
供稿:網(wǎng)友

  眾所周知,微軟公司正在全力打造.Net,并預備將它作為向其他公司進攻的砝碼,來保證其在業(yè)界的技術領先地位。 其實,微軟公司在許多領域都處于領導地位,一些優(yōu)秀的產(chǎn)品讓其他公司難望其項頸,如操作系統(tǒng)
  ,辦公軟件等基于Windows平臺的一些優(yōu)秀的應用軟件(如:IE)。但在美國,許多大公司非常反感微軟一手包辦的作風,也對微軟的不放心,對其產(chǎn)品的安全性的擔憂,所以大部分都用Unix 和linux等非Windows平臺,許多服務器也是用的非Windows平臺,或是用自己開發(fā)的操作系統(tǒng)。但Windows的方便性和界面友好性及眾多的工具也是其他平臺難以比擬的(應該沒什么爭議的),而Unix和Linux平臺似乎只適合一些專家。能不能找到一個橋梁將Windows產(chǎn)品同其他平臺聯(lián)系起來呢?目前有www.stryon.com公司正在實現(xiàn)這一點,開發(fā)了iNet,將Microsoft.Net轉換成java代碼來實現(xiàn)跨平臺。
  
  例如用Visual Studio.Net開發(fā)了一個Web Service程序:
  
  testClient.asmx:
  
  <%@ WebService Language="C#" Class="testClient" %>
  
  
  using System;
  
  using System.Web.Services;
  
  using System.Web.Services.PRotocols;
  
  using System.Web.Services.Description;
  
  using System.xml;
  
  using System.Xml.Schema;
  
  using System.Xml.Serialization;
  
  using System.Data;
  
  
  public class testClient : WebService {
  
  
  [WebMethod()]
  
  public int testInt(int a,int b){
  
  return a+b;
  
  }
  
  
  [WebMethod()]
  
  public strUCt1 testStruct(struct1 a){
  
  return a;
  
  }
  
  
  [WebMethod()]
  
  public int[] testIntArr(int[] a){
  
  return a;
  
  }
  
  
  [WebMethod()]
  
  public struct1[] testStrArr(struct1[] a){
  
  return a;
  
  }
  
  
  [WebMethod()]
  
  public struct1 testStructAndArr(struct1 a,struct1[] b){
  
  return a;
  
  }
  
  
  [WebMethod()]
  
  public struct1[][] testStrManyArr(struct1[][] a){
  
  return a;
  
  }
  
  }
  
  
  public class struct1:parent{
  
  
  public int i=1;
  
  public string j="ok";
  
  public struct2 s2;
  
  }
  
  public class parent{
  
  
  public String p;
  
  }
  
  
  public class struct2{
  
  
  public String sField;
  
  }
  
  
  我們可以用il2java 工具轉換成java代碼(il2java工具可以在www.stryon.com 網(wǎng)站上下載,包括在iNet產(chǎn)品中),如:il2java http://localhost/testClient/testClient.asmx c:/temp,運行這個命令,將在c盤temp目錄下產(chǎn)生 testClient.java 和testClient_Info.java:
  
  testClient.java:
  
  
  import system.*;
  
  import system.Reflection.*;
  
  import system.Web.Services.*;
  
  
  public class testClient extends WebService{
  
  
  public int testInt(int a, int b){
  
  return a+b;
  
  }
  
  
  public struct1 testStruct(struct1 a){
  
  return a;
  
  }
  
  
  public int[] testIntArr(int[] a){
  
  return a;
  
  }
  
  
  public struct1[] testStrArr(struct1[] a){
  
  return a;
  
  }
  
  
  public struct1 testStructAndArr(struct1 a, struct1[] b){
  
  return a;
  
  }
  
  
  public struct1[][] testStrManyArr(struct1[][] a){
  
  return a;
  
  }
  
  
  public testClient(){
  
  super();
  
  
  }
  
  }
  
  用來指明Web Service中有哪些Web方法,以便被客戶調用;
  
  
  testClient_Info.java:
  
  
  import system.*;
  
  import system.Reflection.*;
  
  import system.Web.Services.*;
  
  
  public class testClient_Info implements IMetaData{
  
  
  public void fillType(Type t){
  
  long value = TypeAttributes.AnsiClass.value__ TypeAttributes.AutoLayout.value__ TypeAttributes.BeforeFieldInit.value__ TypeAttributes.Class.value__ TypeAttributes.Public.value__;
  
  TypeAttributes attributes = new TypeAttributes(value);
  
  t.set_Attributes(attributes);
  
  }
  
  
  public FieldInfo[] GetFieldsImpl(Type t){
  
  return new FieldInfo[0];
  
  }
  
  
  public ConstructorInfo[] GetConstructorsImpl(Type t){
  
  long value = 0;
  
  ConstructorInfo ctor = null;
  
  ParameterInfo param = null;
  
  MethodAttributes attributes = null;
  
  ParameterAttributes paramAttrs = null;
  
  java.util.Vector ctorVec = new java.util.Vector();
  
  
  // public testClient();
  
  value = MethodAttributes.HideBySig.value__ MethodAttributes.Public.value__ MethodAttributes.ReuseSlot.value__ MethodAttributes.RTSpecialName.value__ MethodAttributes.SpecialName.value__;
  
  attributes = new MethodAttributes(value);
  
  ctor = new ConstructorInfo(t);
  
  ctorVec.addElement(ctor);
  
  ctor.set_Attributes(attributes);
  
  ctor.set_Name("testClient");
  
  ctor.set_BindingFlags(BindingFlags.Public.value__ BindingFlags.Instance.value__);
  
  
  Object[] objs = ctorVec.toArray();
  
  ctorVec = null;
  
  ConstructorInfo[] ctors = new ConstructorInfo[objs.length];
  
  java.lang.System.arraycopy(objs, 0, ctors, 0, objs.length);
  
  return ctors;
  
  }
  
  
  public MethodInfo[] GetMethodsImpl(Type t){
  
  long value = 0;
  
  MethodInfo method = null;
  
  ParameterInfo param = null;
  
  MethodAttributes attributes = null;
  
  ParameterAttributes paramAttrs = null;
  
  java.util.Vector mdVec = new java.util.Vector();
  
  
  // public int testInt(int a, int b);
  
  value = MethodAttributes.HideBySig.value__ MethodAttributes.Public.value__ MethodAttributes.ReuseSlot.value__;
  
  attributes = new MethodAttributes(value);
  
  method = new MethodInfo(t);
  
  mdVec.addElement(method);
  
  method.set_Attributes(attributes);
  
  method.set_Name("testInt");
  
  method.set_ReturnType("System.Int32");
  
  method.set_BindingFlags(BindingFlags.Public.value__ BindingFlags.Instance.value__);
  
  value = 0;
  
  paramAttrs = new ParameterAttributes(value);
  
  param = new ParameterInfo(method);
  
  param.set_Attributes(paramAttrs);
  
  param.set_Name("a");
  
  param.set_ParamType("System.Int32");
  
  method.addParameterInfo(param);
  
  value = 0;
  
  paramAttrs = new ParameterAttributes(value);
  
  param = new ParameterInfo(method);
  
  param.set_Attributes(paramAttrs);
  
  param.set_Name("b");
  
  param.set_ParamType("System.Int32");
  
  method.addParameterInfo(param);
  
  
  // public struct1 testStruct(struct1 a);
  
  value = MethodAttributes.HideBySig.value__ MethodAttributes.Public.value__ MethodAttributes.ReuseSlot.value__;
  
  attributes = new MethodAttributes(value);
  
  method = new MethodInfo(t);
  
  mdVec.addElement(method);
  
  method.set_Attributes(attributes);
  
  method.set_Name("testStruct");
  
  method.set_ReturnType("struct1");
  
  method.set_BindingFlags(BindingFlags.Public.value__ BindingFlags.Instance.value__);
  
  value = 0;

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 留坝县| 阳新县| 顺义区| 陈巴尔虎旗| 怀来县| 陆河县| 汕尾市| 江津市| 阆中市| 虎林市| 金川县| 平定县| 泰兴市| 双辽市| 怀来县| 葵青区| 两当县| 台江县| 莆田市| 张家川| 遵化市| 醴陵市| 津南区| 镇平县| 宁强县| 武山县| 克什克腾旗| 普洱| 兴山县| 九寨沟县| 德江县| 安康市| 青州市| 舞阳县| 永济市| 车险| 蚌埠市| 蒲城县| 高邮市| 射阳县| 兴化市|