コード例 #1
0
 void executePrivate( )
 {
     /* GeneXus formulas */
     /* Output device settings */
     context.nSOAPErr         = 0;
     context.sSOAPErrMsg      = "";
     GXSoapHTTPClient.Host    = context.GetServerName( );
     GXSoapHTTPClient.Port    = context.GetServerPort( );
     GXSoapHTTPClient.BaseURL = context.GetScriptPath( );
     SoapParm.AssignLocationProperties(context, "AwsCalcularPasajeros", GXSoapHTTPClient);
     GXSoapHTTPClient.AddHeader("Content-type", "text/xml;charset=utf-8");
     GXSoapHTTPClient.AddHeader("SOAPAction", "CalcularPeajesaction/" + "AWSCALCULARPASAJEROS.Execute");
     GXSoapXMLWriter.OpenRequest(GXSoapHTTPClient);
     GXSoapXMLWriter.WriteStartDocument("utf-8", 0);
     GXSoapXMLWriter.WriteStartElement("SOAP-ENV:Envelope");
     GXSoapXMLWriter.WriteAttribute("xmlns:SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
     GXSoapXMLWriter.WriteAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
     GXSoapXMLWriter.WriteAttribute("xmlns:SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
     GXSoapXMLWriter.WriteAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
     GXSoapXMLWriter.WriteStartElement("SOAP-ENV:Body");
     GXSoapXMLWriter.WriteStartElement("Execute");
     GXSoapXMLWriter.WriteAttribute("xmlns", "CalcularPeajes");
     GXSoapXMLWriter.WriteElement("Paxitc", StringUtil.Trim(StringUtil.Str((decimal)(AV2PAXITC), 10, 0)));
     GXSoapXMLWriter.WriteAttribute("xmlns", "http://tempuri.org/");
     GXSoapXMLWriter.WriteElement("Trb", StringUtil.Trim(StringUtil.Str((decimal)(AV3TRB), 10, 0)));
     GXSoapXMLWriter.WriteAttribute("xmlns", "http://tempuri.org/");
     GXSoapXMLWriter.WriteElement("Cpsuab", StringUtil.Trim(StringUtil.Str((decimal)(AV4CPSUAB), 10, 0)));
     GXSoapXMLWriter.WriteAttribute("xmlns", "http://tempuri.org/");
     GXSoapXMLWriter.WriteEndElement();
     GXSoapXMLWriter.WriteEndElement();
     GXSoapXMLWriter.WriteEndElement();
     GXSoapXMLWriter.Close();
     GXSoapHTTPClient.Execute("POST", "awscalcularpasajeros.aspx");
     if (GXSoapHTTPClient.ErrCode != 0)
     {
         currSoapErr    = (short)(GXSoapHTTPClient.ErrCode * -1 - 10000);
         currSoapErrmsg = GXSoapHTTPClient.ErrDescription;
     }
     GXSoapXMLReader.OpenResponse(GXSoapHTTPClient);
     GXSoapError = GXSoapXMLReader.Read();
     while (GXSoapError > 0)
     {
         if (StringUtil.StringSearch(GXSoapXMLReader.Name, "Body", 1) > 0)
         {
             if (true)
             {
                 break;
             }
         }
         GXSoapError = GXSoapXMLReader.Read();
     }
     if (GXSoapError > 0)
     {
         GXSoapError = GXSoapXMLReader.Read();
         if ((GXSoapError > 0) && (StringUtil.StrCmp(GXSoapXMLReader.LocalName, "Fault") == 0))
         {
             soapFault = 1;
         }
     }
     sTagName = GXSoapXMLReader.Name;
     if (GXSoapXMLReader.IsSimple == 0)
     {
         if (soapFault == 0)
         {
             GXSoapError = GXSoapXMLReader.Read();
             if ((GXSoapError > 0) && (StringUtil.StrCmp(GXSoapXMLReader.LocalName, "Fault") == 0))
             {
                 soapFault = 1;
             }
         }
         if (soapFault == 1)
         {
             GXSoapXMLReader.Read();
             while (!((StringUtil.StrCmp(GXSoapXMLReader.LocalName, "Fault") == 0) && (GXSoapXMLReader.NodeType == 2)))
             {
                 if (StringUtil.StrCmp(StringUtil.Lower(GXSoapXMLReader.Name), "faultcode") == 0)
                 {
                     sFaultCode = GXSoapXMLReader.Value;
                 }
                 else if (StringUtil.StrCmp(StringUtil.Lower(GXSoapXMLReader.Name), "faultstring") == 0)
                 {
                     sFaultString = GXSoapXMLReader.Value;
                 }
                 else if (StringUtil.StrCmp(StringUtil.Lower(GXSoapXMLReader.Name), "detail") == 0)
                 {
                     if (GXSoapXMLReader.IsSimple == 0)
                     {
                         GXSoapXMLReader.Read();
                         sDetail = GXSoapXMLReader.ReadRawXML();
                     }
                     else
                     {
                         sDetail = GXSoapXMLReader.Value;
                     }
                 }
                 GXSoapXMLReader.Read();
             }
             if (StringUtil.StringSearch(StringUtil.Lower(sFaultCode), "client", 1) > 0)
             {
                 currSoapErr    = (short)(-20004);
                 currSoapErrmsg = currSoapErrmsg + "SOAP Fault: Error in client request." + StringUtil.NewLine( ) + "Message: " + sFaultString + StringUtil.NewLine( ) + "Detail: " + sDetail;
             }
             else if (StringUtil.StringSearch(StringUtil.Lower(sFaultCode), "server", 1) > 0)
             {
                 currSoapErr    = (short)(-20005);
                 currSoapErrmsg = currSoapErrmsg + "SOAP Fault: Error in server execution." + StringUtil.NewLine( ) + "Message: " + sFaultString + StringUtil.NewLine( ) + "Detail: " + sDetail;
             }
             else
             {
                 currSoapErr    = (short)(-20006);
                 currSoapErrmsg = currSoapErrmsg + "Unknown error: " + sFaultCode + StringUtil.NewLine( ) + "Message: " + sFaultString + StringUtil.NewLine( ) + "Detail: " + sDetail;
             }
         }
         else
         {
             nOutParmCount = 0;
             while (((StringUtil.StrCmp(GXSoapXMLReader.Name, sTagName) != 0) || (GXSoapXMLReader.NodeType == 1)) && (GXSoapError > 0))
             {
                 readOk = 0;
                 if (StringUtil.StrCmp2(GXSoapXMLReader.LocalName, "Resultado") && (GXSoapXMLReader.NodeType != 2) && (StringUtil.StrCmp(GXSoapXMLReader.NamespaceURI, "http://tempuri.org/") == 0))
                 {
                     AV5Resultado = GXSoapXMLReader.Value;
                     if (GXSoapError > 0)
                     {
                         readOk = 1;
                     }
                     GXSoapError = GXSoapXMLReader.Read();
                 }
                 nOutParmCount = (short)(nOutParmCount + 1);
                 if (readOk == 0)
                 {
                     context.sSOAPErrMsg = context.sSOAPErrMsg + "Error reading " + sTagName + StringUtil.NewLine( );
                     context.sSOAPErrMsg = context.sSOAPErrMsg + "Message: " + GXSoapXMLReader.ReadRawXML();
                     GXSoapError         = (short)(nOutParmCount * -1);
                 }
             }
         }
     }
     GXSoapXMLReader.Close();
     if (currSoapErr == 0)
     {
         if (GXSoapError < 0)
         {
             currSoapErr    = (short)(GXSoapError * -1);
             currSoapErrmsg = context.sSOAPErrMsg;
         }
         else
         {
             if (GXSoapXMLReader.ErrCode > 0)
             {
                 currSoapErr    = (short)(GXSoapXMLReader.ErrCode * -1);
                 currSoapErrmsg = GXSoapXMLReader.ErrDescription;
             }
             else
             {
                 if (GXSoapError == 0)
                 {
                     currSoapErr    = (short)(-20001);
                     currSoapErrmsg = "Malformed SOAP message.";
                 }
                 else
                 {
                     currSoapErr    = 0;
                     currSoapErrmsg = "No error.";
                 }
             }
         }
     }
     if (currSoapErr != 0)
     {
         oLocation = SoapParm.getlocation(context, "AwsCalcularPasajeros");
         if (oLocation.CancelOnError == 1)
         {
             throw new Exception(currSoapErrmsg + "(" + StringUtil.LTrim(StringUtil.NToC((decimal)(currSoapErr), 6, 0, ".", "")) + ")");
         }
     }
     context.nSOAPErr    = currSoapErr;
     context.sSOAPErrMsg = currSoapErrmsg;
     this.cleanup();
 }
コード例 #2
0
        public String execute( )
        {
            String returnexecute;

            returnexecute            = "";
            context.nSOAPErr         = 0;
            context.sSOAPErrMsg      = "";
            GXSoapHTTPClient.Host    = "tise-wks-345508.canal.acp";
            GXSoapHTTPClient.Port    = 80;
            GXSoapHTTPClient.BaseURL = "/CalcularPeajes.NetEnvironment/";
            SoapParm.AssignLocationProperties(context, "wsrest_services", GXSoapHTTPClient);
            if (StringUtil.StrCmp(defaultExecute, "") == 0)
            {
                targetResourceName = (String)(SoapParm.GetResourceName(context, "wsrest_services"));
                if (StringUtil.StrCmp(targetResourceName, "") == 0)
                {
                    execName = "wsrest.svc";
                }
                else
                {
                    execName = targetResourceName;
                }
            }
            else
            {
                execName = defaultExecute;
            }
            GXSoapHTTPClient.AddHeader("Content-type", "text/xml;charset=utf-8");
            GXSoapHTTPClient.AddHeader("SOAPAction", "GeneXus.Programs.wsrest_services/wsrest_services/execute");
            GXSoapXMLWriter.OpenRequest(GXSoapHTTPClient);
            GXSoapXMLWriter.WriteStartDocument("utf-8", 0);
            GXSoapXMLWriter.WriteStartElement("SOAP-ENV:Envelope");
            GXSoapXMLWriter.WriteAttribute("xmlns:SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
            GXSoapXMLWriter.WriteAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
            GXSoapXMLWriter.WriteAttribute("xmlns:SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/");
            GXSoapXMLWriter.WriteAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            if (!(soapHeaders == null))
            {
                if (soapHeaders.Count > 0)
                {
                    soapHeaders.writexml(GXSoapXMLWriter, "SOAP-ENV:Header", "");
                }
            }
            else
            {
                if (!(String.IsNullOrEmpty(StringUtil.RTrim(soapHeadersRaw))))
                {
                    GXSoapXMLWriter.WriteStartElement("SOAP-ENV:Header");
                    GXSoapXMLWriter.WriteRawText(soapHeadersRaw);
                    GXSoapXMLWriter.WriteEndElement();
                }
            }
            GXSoapXMLWriter.WriteStartElement("SOAP-ENV:Body");
            GXSoapXMLWriter.WriteElement("execute", "");
            GXSoapXMLWriter.WriteAttribute("xmlns", "GeneXus.Programs.wsrest_services");
            GXSoapXMLWriter.WriteEndElement();
            GXSoapXMLWriter.WriteEndElement();
            GXSoapXMLWriter.Close();
            GXSoapHTTPClient.Execute("POST", execName);
            if (GXSoapHTTPClient.ErrCode != 0)
            {
                currSoapErr    = (short)(GXSoapHTTPClient.ErrCode * -1 - 10000);
                currSoapErrmsg = GXSoapHTTPClient.ErrDescription;
            }
            GXSoapXMLReader.OpenResponse(GXSoapHTTPClient);
            GXSoapError = GXSoapXMLReader.Read();
            while (GXSoapError > 0)
            {
                if (StringUtil.StringSearch(GXSoapXMLReader.Name, "Body", 1) > 0)
                {
                    if (true)
                    {
                        break;
                    }
                }
                GXSoapError = GXSoapXMLReader.Read();
            }
            if (GXSoapError > 0)
            {
                GXSoapError = GXSoapXMLReader.Read();
                if ((GXSoapError > 0) && (StringUtil.StrCmp(GXSoapXMLReader.LocalName, "Fault") == 0))
                {
                    soapFault = 1;
                }
            }
            sTagName = GXSoapXMLReader.Name;
            if (GXSoapXMLReader.IsSimple == 0)
            {
                if (soapFault == 0)
                {
                    GXSoapError = GXSoapXMLReader.Read();
                    if ((GXSoapError > 0) && (StringUtil.StrCmp(GXSoapXMLReader.LocalName, "Fault") == 0))
                    {
                        soapFault = 1;
                    }
                }
                if (soapFault == 1)
                {
                    soapFaultHandling( );
                }
                else
                {
                    nOutParmCount = 0;
                    while (((StringUtil.StrCmp(GXSoapXMLReader.Name, sTagName) != 0) || (GXSoapXMLReader.NodeType == 1)) && (GXSoapError > 0))
                    {
                        readOk = 0;
                        if (StringUtil.StrCmp2(GXSoapXMLReader.LocalName, "Resultado") && (GXSoapXMLReader.NodeType != 2) && (StringUtil.StrCmp(GXSoapXMLReader.NamespaceURI, "GeneXus.Programs.wsrest_services") == 0))
                        {
                            returnexecute = GXSoapXMLReader.Value;
                            if (GXSoapError > 0)
                            {
                                readOk = 1;
                            }
                            GXSoapError = GXSoapXMLReader.Read();
                        }
                        nOutParmCount = (short)(nOutParmCount + 1);
                        if (readOk == 0)
                        {
                            context.sSOAPErrMsg = context.sSOAPErrMsg + "Error reading " + sTagName + StringUtil.NewLine( );
                            context.sSOAPErrMsg = context.sSOAPErrMsg + "Message: " + GXSoapXMLReader.ReadRawXML();
                            GXSoapError         = (short)(nOutParmCount * -1);
                        }
                    }
                }
            }
            GXSoapXMLReader.Close();
            if (currSoapErr == 0)
            {
                if (GXSoapError < 0)
                {
                    currSoapErr    = (short)(GXSoapError * -1);
                    currSoapErrmsg = context.sSOAPErrMsg;
                }
                else
                {
                    if (GXSoapXMLReader.ErrCode > 0)
                    {
                        currSoapErr    = (short)(GXSoapXMLReader.ErrCode * -1);
                        currSoapErrmsg = GXSoapXMLReader.ErrDescription;
                    }
                    else
                    {
                        if (GXSoapError == 0)
                        {
                            currSoapErr    = (short)(-20001);
                            currSoapErrmsg = "Malformed SOAP message.";
                        }
                        else
                        {
                            currSoapErr    = 0;
                            currSoapErrmsg = "No error.";
                        }
                    }
                }
            }
            if (currSoapErr != 0)
            {
                oLocation = SoapParm.getlocation(context, "wsrest_services");
                if ((oLocation.CancelOnError == 0) || (oLocation.CancelOnError == 1))
                {
                    throw new Exception(currSoapErrmsg + "(" + StringUtil.LTrim(StringUtil.NToC((decimal)(currSoapErr), 6, 0, ".", "")) + ")");
                }
            }
            context.nSOAPErr    = currSoapErr;
            context.sSOAPErrMsg = currSoapErrmsg;
            return(returnexecute);
        }