从coldfusion中使用.NET中的复杂类型的restful webservice

时间:2013-12-10 06:11:58

标签: web-services rest coldfusion complextype

我在ColdFusion中遇到了如何设置需要宁静的.NET Web服务的复杂参数的问题。实际上我有下一个代码,但是当我使用Ws时,我有消息“对象引用未设置为对象的实例。”所以,我认为我的CF代码是错误的。

<cfset dotnetstring = createObject(".net", "System.String", "dotNetCoreProxy.jar")>

<cfset ClienteList = CreateObject(".net","System.Collections.Generic.List`1", "dotNetCoreProxy.jar").init(dotnetstring.getDotNetClass())>
<cfset CoberturaList = CreateObject(".net","System.Collections.Generic.List`1", "dotNetCoreProxy.jar").init(dotnetstring .getDotNetClass())>
<cfset IncisoList = CreateObject(".net","System.Collections.Generic.List`1", "dotNetCoreProxy.jar").init(dotnetstring.getDotNetClass())>
<cfset ClausulaList = CreateObject(".net","System.Collections.Generic.List`1", "dotNetCoreProxy.jar").init(dotnetstring.getDotNetClass())>
<cfset CuotaList = CreateObject(".net","System.Collections.Generic.List`1", "dotNetCoreProxy.jar").init(dotnetstring.getDotNetClass())>
<cfset ObservacionList = CreateObject(".net","System.Collections.Generic.List`1", "dotNetCoreProxy.jar").init(dotnetstring.getDotNetClass())>







<cfset myEmission = StructNew()>
<cfset myEmission.Emission.codSuc = "30">
<cfset myEmission.Emission.codRamo = "200">
<cfset myEmission.Poliza.numPol = "0">
<cfset myEmission.Poliza.anioEndoso = "0">
<cfset myEmission.Poliza.numEndoso = "0">
<cfset myEmission.Poliza.codMoneda = "0">
<cfset myEmission.Poliza.codTipoPoliza = "4">
<cfset myEmission.Poliza.fecVigDesde = "30/11/2013">
<cfset myEmission.Poliza.fecVigHasta = "30/11/2014">
<cfset myEmission.agente.codTipoAgente = "1">
<cfset myEmission.agente.codAgente = "1000">

<cfset ClienteList.add("{apPat='Casey'}")>
<cfset ClienteList.add("{apMat='Walker'}")>
<cfset ClienteList.add("{nombre='Tom'}")>
<cfset ClienteList.add("{tipoPersona='J'}")>
<cfset ClienteList.add("{codItem='0'}")>
<!---<cfdump var="#ClienteList.Get_Count()#">--->
<cfset myEmission.Cliente = ClienteList>

<cfset CoberturaList.add("{codItem=12}")>
<cfset CoberturaList.add("{codIndCob=999}")>
<cfset CoberturaList.add("{codRamo=5}")>
<cfset CoberturaList.add("{codTarifa=13}")>
<cfset CoberturaList.add("{codObjeto=999}")>
<cfset myEmission.Cobertura = CoberturaList>

<cfset IncisoList.add("{codItem=0}")>
<cfset IncisoList.add("{codIndCob=77}")>
<cfset myEmission.Inciso = IncisoList>

<cfset ClausulaList.add("{codTipoAnexo=25}")>
<cfset ClausulaList.add("{codAnexo=50}")>
<cfset myEmission.Clausula = ClausulaList>

<cfset CuotaList.add("{numCuota=6}")>
<cfset CuotaList.add("{codItem=5}")>
<cfset CuotaList.add("{fecVenc='31/12/2013'}")>
<cfset CuotaList.add("{impPrimaMe='440.44m'}")>
<cfset CuotaList.add("{impIvaMe='33.33m'}")>
<cfset CuotaList.add("{impRecFinMe='22m'}")>
<cfset CuotaList.add("{impDerPoliza='11m'}")>
<cfset CuotaList.add("{impDerPolizaTur='0m'}")>
<cfset CuotaList.add("{impPremio='1010m'}")>
<cfset myEmission.Cuota = CuotaList>

<cfset ObservacionList.add("{codItem=7}")>
<cfset myEmission.Observacion = ObservacionList>

<cfset myEmission.Observacion.codItem = "7">

<!---<cfdump var="#myEmission#">--->




<cfset ws= createobject("webservice","http://somedomain.com.mx/IntegrationService/EmissionService.svc?wsdl") >

<cfset aString = ws.createPolicy(#myEmission#) >

<cfdump var="#aString#">

我有如何使用NET的web服务的示例。我的问题是如何在CF中设置对象。

protected void Button1_Click(object sender, EventArgs e)
    {
        //Create Emission object in order to manage entities for emission process
        IntegrationService.Emission myEmission = new IntegrationService.Emission();
        myEmission.codSuc = 30;
        myEmission.codRamo = 200;
        myEmission.poliza = new IntegrationService.Poliza() { 
                                                              //These must be initialized from WS
                                                              numPol = "0", 
                                                              anioEndoso = 0, 
                                                              numEndoso = "0",
                                                              //
                                                              codMoneda = 0, 
                                                              codTipoPoliza = 4, 
                                                              fecVigDesde = new DateTime(2013,11,30),
                                                              fecVigHasta = new DateTime(2014,11,30)
                                                            };
        myEmission.agente = new IntegrationService.Agente() { 
                                                              codTipoAgente = 1,
                                                              codAgente = 1000
                                                            };
        myEmission.cliente = new System.Collections.Generic.List<IntegrationService.Cliente>(){
                                            new IntegrationService.Cliente()
                                            {
                                                apPat = "Casey",
                                                apMat = "Walker",
                                                nombre = "Tom",
                                                tipoPersona = "J",
                                                codItem = 0
                                            }
                                          };
        myEmission.cobertura = new System.Collections.Generic.List<IntegrationService.Cobertura>(){
                                                new IntegrationService.Cobertura() 
                                                {
                                                    codItem = 12,
                                                    codIndCob = 999,
                                                    codRamo = 5,
                                                    codTarifa = "13",
                                                    codObjeto = "999"
                                                }
                                            };
        myEmission.inciso = new System.Collections.Generic.List<IntegrationService.Inciso>(){
                                                new IntegrationService.Inciso()
                                                {
                                                    codItem = 0,
                                                    codIndCob = 77
                                                }
                                            };
        myEmission.clausula = new System.Collections.Generic.List<IntegrationService.Clausula>(){
                                                new IntegrationService.Clausula()
                                                {
                                                    codTipoAnexo = 25,
                                                    codAnexo = 50
                                                }
                                            };
        myEmission.cuota = new System.Collections.Generic.List<IntegrationService.Cuota>(){
                                                new IntegrationService.Cuota()
                                                {
                                                    numCuota = 6,
                                                    codItem = 5,
                                                    fecVenc = new DateTime(2013,12,31),
                                                    impPrimaMe = 440.44m,
                                                    impIvaMe = 33.33m,
                                                    impRecFinMe = 22m,
                                                    impDerPoliza = 11m,
                                                    impDerPolizaTur = 0m,
                                                    impPremio = 1010m
                                                }
                                            };
        myEmission.observacion = new System.Collections.Generic.List<IntegrationService.Observacion>(){
                                                new IntegrationService.Observacion()
                                                {
                                                    codItem = 7
                                                }
                                            };
        //Instantiate service as client

        IntegrationService.EmissionServiceClient myServiceClient = new IntegrationService.EmissionServiceClient();
        //Open service client request
        myServiceClient.Open();
        //Call specified WebMethod as necessary, sending Emission object as parameter
        result = myServiceClient.createPolicy(myEmission);
        //Close service client request
        myServiceClient.Close();

        Label1.Text = result;
    }

我希望有人可以帮我提供任何暗示。

问候!

0 个答案:

没有答案