Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoke NET webservice(svc) with data complext

Status
Not open for further replies.

zamvil

Programmer
Jul 25, 2002
9
MX
I'm trying to invoke a NET webservice type REST but I have problems because first, I have to get the values and send like a object.

I put the values in structs but someones I have to puthem in a list, I think so. The NET developers send me a sample of how can I invoke in net and this code Im trying to translate in CF.

This is NET Code

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 = "Morales",
apMat = "Ibarra",
nombre = "Osiris",
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;
}


An this is my code in CF


<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 myEmission.Cliente.apPat = "Zamora">
<cfset myEmission.Cliente.apMat = "Villasana">
<cfset myEmission.Cliente.nombre = "Moises">
<cfset myEmission.Cliente.tipoPersona = "J">
<cfset myEmission.Cliente.tipoPersona = "0">


<cfset myEmission.Cobertura.codItem = "12">
<cfset myEmission.Cobertura.codIndCob = "999">
<cfset myEmission.Cobertura.codRamo = "5">
<cfset myEmission.Cobertura.codTarifa = "13">
<cfset myEmission.Cobertura.codObjeto = "999">


<cfset myEmission.Inciso.codItem = "0">
<cfset myEmission.Inciso.codIndCob = "77">


<cfset myEmission.Clausula.codTipoAnexo = "25">
<cfset myEmission.Clausula.codAnexo = "50">


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


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


<cfinvoke
webservice="method="createPolicy"
returnvariable="aString" argumentcollection="#myEmission#">
<cfinvokeargument name="emissionRequest" value=""/>
</cfinvoke>


<cfdump var="#aString#">


This part I don't know how to translate in CF, If some can help me please.

myEmission.cliente = new System.Collections.Generic.List<IntegrationService.Cliente>(){
new IntegrationService.Cliente()
{
apPat = "Morales",
apMat = "Ibarra",
nombre = "Osiris",
tipoPersona = "J",
codItem = 0
}
};



Do you know where can I found a sample of how to send this parameters to Net webservice from CF?
No there's much informacion about this.

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top