0

Visual Studio で作成された webreference を使用せずに Web サービスを呼び出す必要があります。http Web 要求を使用する必要があります。soap 要求があります。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pos="http://posting.ws.rpg.snamretegas.it/">
   <soapenv:Header/>
      <soapenv:Body>
         <pos:postAllReports>

            <report_name>REPORT_SWITCH</report_name>

            <report_date></report_date>

            <i_ambiente>ITG1</i_ambiente>

            <i_taxidOpco>TEST_YF1</i_taxidOpco>
         </pos:postAllReports>
      </soapenv:Body>
   </soapenv:Envelope>

これは、ASP ページの背後にあるコードです。

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OracleClient;


public partial class PubreportControl : System.Web.UI.Page 
{   
   private DB_Utility dbu;
   protected double size = 1;
   private string connectionString;
   private OracleConnection connection;
   private OracleCommand processNumQuery;
   private int indexdropitem;
   private int coloreriga = 1;

   protected void Page_Load(object sender, EventArgs e)
   {


    if (!IsPostBack)
    {
        Session["CONNECTSTRING"] = Request["CONNECTSTRING"];

        if (Session["CONNECTSTRING"] == null)
        {
            Response.Redirect("sessionup.asp?type=Pubreport");
        }

        connectionString = Session["CONNECTSTRING"].ToString();

        if (connectionString.IndexOf("DSN=") >= 0)
        {
            Comuni.Utility util = new Utility();
            connectionString = util.ConnStr(connectionString);
            Session["CONNECTSTRING"] = connectionString;
        }
        connection = new OracleConnection(connectionString);
        connection.Open();
        dbu = new DB_Utility(Session["CONNECTSTRING"].ToString());

    }
    else
    {
        connectionString = Session["CONNECTSTRING"].ToString();
        if (connectionString.IndexOf("DSN=") >= 0)
        {
            Comuni.Utility util = new Utility();
            connectionString = util.ConnStr(connectionString);
            Session["CONNECTSTRING"] = connectionString;
        }
        connection = new OracleConnection(connectionString);
        connection.Open();
        dbu = new DB_Utility(Session["CONNECTSTRING"].ToString());
    }

    if (!IsPostBack)
    {
            processNumQuery = new OracleCommand("select distinct nome_report from rpg_notification",connection);
            OracleDataReader reader = processNumQuery.ExecuteReader();

            while (reader.Read())
            {
                dropdownlist1.Items.Insert(0, new ListItem(reader.GetString(0), reader.GetString(0)));
            }
            reader.Close();

    }
    if(Request["txtSchedDate"] == null)
    {
         DateTime daDate = DateTime.Today;
         txtSchedDate.Text = daDate.ToString("dd/MM/yyyy");
    }
    else
    {
         txtSchedDate.Text = Request["txtSchedDate"];
         gwreportpub.DataSource = getDatiFromDb();
         gwreportpub.DataBind();


        DateTime schedDate = Convert.ToDateTime(Request["txtSchedDate"]);
        string reportname = dropdownlist1.SelectedItem.Text; 
        object[] WSMethodArguments = new object[3];
        WSMethodArguments[0] = reportname;
        WSMethodArguments[1] = schedDate.ToUniversalTime().ToString("s");
        WSMethodArguments[2] = "ITG1";
        PageAsyncTask task = new PageAsyncTask(
        new BeginEventHandler(BeginAsyncOperation),
        new EndEventHandler(EndAsyncOperation),
        new EndEventHandler(TimeoutAsyncOperation),
        WSMethodArguments
        );
        RegisterAsyncTask(task);
    }

   }


   protected void Button1_Click(object sender, EventArgs e)
   {

    //Response.Write("ciao " + dropdownlist1.SelectedIndex + " - " + dropdownlist1.SelectedItem.Text + " - " + dropdownlist1.Items[dropdownlist1.SelectedIndex].Text + " - " + Request["txtSchedDate"] + " - ");

    //ThreadPool.QueueUserWorkItem(new WaitCallback(callWebService),new object[] {"http://172.19.241.235:9001/snam-rpg-ws/ReportPosting","ReportPosting","postAllReports",WSMethodArguments});  

    gwreportpub.DataSource = getDatiFromDb();
    gwreportpub.DataBind();
    gwreportpub.Visible = true;
    if (gwreportpub.Rows.Count == 0)
    {   
            tbnotif.Text = "Non vi sono report pubblicati";
            tbnotif.Visible = true;
    }
    else{
        tbnotif.Visible = true;
        tbnotif.Text = "Tabella dei Report Pubblicati: ";
    }
    return;


   }
   void TimeoutAsyncOperation(IAsyncResult ar)
   {
    Response.Write("Pubblicazione Timeout");
   }
   IAsyncResult BeginAsyncOperation (object sender, EventArgs e, 
    AsyncCallback cb, object state)
    {

    object[] array = state as object[];

    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"http://172.19.241.235:9001/snam-rpg-ws/ReportPosting"); 
    webRequest.Headers.Add(@"SOAP:Action"); 
    webRequest.ContentType = "text/xml;charset=\"utf-8\""; 
    webRequest.Accept = "text/xml"; 
    webRequest.Method = "POST"; 

    HttpWebRequest request = webRequest;
    XmlDocument soapEnvelopeXml = new XmlDocument();
    soapEnvelopeXml.LoadXml("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:pos=\"http://posting.ws.rpg.snamretegas.it/\"><soapenv:Header/><soapenv:Body><pos:postAllReports><report_name> " + array[0] +" </report_name> <report_date> " + array[1] + "</report_date> <i_ambiente> " + array[2] + "</i_ambiente> <i_taxidOpco></i_taxidOpco></pos:postAllReports></soapenv:Body></soapenv:Envelope>");

    using (Stream stream = request.GetRequestStream()) 
    { 
        soapEnvelopeXml.Save(stream); 
    }

    using (WebResponse response = request.GetResponse())
    {
        using (StreamReader rd = new StreamReader(response.GetResponseStream())) 
        { 
            string soapResult = rd.ReadToEnd();

        } 
    }

    SampleMethodCaller smd = new SampleMethodCaller(SampleClass.SampleMethod);
    IAsyncResult result = smd.BeginInvoke(null, null);
    return result;
    //return callWebService(new object[] {"http://172.19.241.235:9001/snam-rpg-ws/ReportPosting","ReportPosting","postAllReports",state});

}
public delegate bool SampleMethodCaller();

void EndAsyncOperation(IAsyncResult ar)
{
    Response.Write("Pubblicazione Terminata");
}

protected void Page_PreRenderComplete(object sender, EventArgs e)
{

}

   public DataSet getDatiFromDb()
   {
        OracleDataAdapter adapter = new OracleDataAdapter();
        OracleCommand orclc = new OracleCommand("select pubblicato, nome_report, data_report, md5 from rpg_notification where pubblicato = :flag and data_report <= TO_DATE(:repdate,'DD/MM/YYYY') and nome_report = :nome",this.connection);
        orclc.Parameters.Add(new OracleParameter(":flag", OracleType.VarChar));
        orclc.Parameters.Add(new OracleParameter(":nome", OracleType.VarChar));
        orclc.Parameters.Add(new OracleParameter(":repdate", OracleType.VarChar));
        orclc.Parameters[":flag"].Value = "Y";
        orclc.Parameters[":nome"].Value = dropdownlist1.SelectedItem.Text;
        orclc.Parameters[":repdate"].Value = Request["txtSchedDate"].ToString();

        adapter.SelectCommand = orclc;

        DataSet dt = new DataSet("rpg_notification");   
        adapter.Fill(dt,"rpg_notification");
        return dt;
   }
    protected void GridView1_PageIndexChanging(object sender,
GridViewPageEventArgs e)
    {
    gwreportpub.PageIndex = e.NewPageIndex;
    gwreportpub.DataBind();
    }
   protected void coloraRighe(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType==DataControlRowType.Header)
    {
        e.Row.BackColor = Color.Ivory;
    }

    else if (coloreriga == 2)
    {
        e.Row.BackColor = Color.LightYellow;
        coloreriga = 1;
    }
    else
    {
        e.Row.BackColor = Color.WhiteSmoke;
        coloreriga = 2;
    }
    }

}


public class SampleClass
    {
        public static bool SampleMethod()
        {

        return true;
        }

    }

Wsを呼ばない理由を教えてください???

どうすればこれをデバッグできますか??? コードに何か問題がありますか??

私も非同期パターンに夢中になっています

最後にaspページ:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Pubreport.aspx.cs"
Inherits="PubreportControl" Title="Untitled Page"  Async="true" %>

 <html xmlns="http://www.w3.org/1999/xhtml" >

  <script language="javascript" type="text/javascript">
     var size = 0;
     var id= 0;

  function add_gif() {
    document.getElementById("Label1").style.display = "none";       
         show_image("./wait.gif", 300,15, "Running");
 }


 function show_image(src, width, height, alt) {
    var img = document.createElement("img");
    img.src = src;
    img.width = width;
    img.height = height;
    img.alt = alt;
    document.getElementById("divUpload").style.display="inline";
    var div = document.getElementById("divUpload");
    div.appendChild(img);
 }

 function show_table() {
    document.getElementById("tbnotification").style.display="block";
 }

 </script>

 <head id="Head1" runat="server">
     <title>Pubblicazione Report</title>
<link rel="stylesheet" type="text/css" href="../controls/SnapIn.css" />
     <link rel="stylesheet" type="text/css" href="../controls/lsi18n.css" />

     <script type="text/javascript" src="../cust_batchrequest/calendario/prototype.js"></script>

     <script type="text/javascript" src="../cust_batchrequest/calendario/scriptaculous.js">     </script>

<script type="text/javascript" src="../cust_batchrequest/calendario/datepicker.js"></script>


     <link rel="stylesheet" type="text/css" href="../cust_batchrequest/calendario/datepicker.css" />


<style type="text/css">
    .errorMessage
    {
        color: #8B0000;
        text-align: center;
    }
    .confirmMessage
    {
        color: #006400;
        text-align: center;
    }
    .datebox
    {
        text-align:center;
    }
</style>
<style type="text/css"> 
    .CCSListBox 
    { 
        width: 200px; 
    }
</style>    
 </head>

 <body style="margin-left: 20%; margin-right: 20%">

<form id="form1" runat="server">
<table class="SnapIn" style="text-align: center; height: 100%; border: 0; background-color: #FFFFFF; width: 100%;
    border: 3px solid #6699CC" cellpadding="0" cellspacing="0">
    <tr class="ToolsRow">
        <td class="Title" style="white-space: nowrap; width=20%">
            Pubblicazione Report
        </td>
        <td style="width: 80%; text-align: right">

        </td>
    </tr>
    <tr style="height: 5%">
        <td colspan="2">
            &nbsp;
        </td>
    </tr>
    <tr style="text-align: center;">

    </tr>
    <tr style="height: 15%">
        <td colspan="2">
            &nbsp;
        </td>
    </tr>
    <tr>

        <td style="text-align: center" colspan="2"> 
        <div style="text-align:center">
             <b>Scegliere il nome del report *  </b>  &nbsp;
             <asp:DropDownList id="dropdownlist1" style="width:250px;" runat="server"></asp:DropDownList>
            <br />
            <br /> 
            <br /> 
            <b>Scegliere la data del report </b>  &nbsp; 
            <asp:TextBox runat="server" ID="txtSchedDate" name="txtSchedDate" type="text" cssclass="datebox" style="height:20px;" ReadOnly="true"/>
            <br />
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" Text="Pubblica" OnClientClick="show_table();" OnCommand="Button1_Click" />
            <br />
            <br />
            <br />
            <br />
            <asp:Label ID="Label1" Font-Names="Arial" Font-Size="15px" runat="server" ForeColor="Red" Font-Bold="True" Text=""></asp:Label>
            <div id="divUpload" style="display:none">
            <div  style="width:200pt;;text-align:center;">Pubblicando...</div>
            </div>
        </div>
        </td>
    <br/>
    </tr>


    <tr>
        <td colspan="2" style="text-align: center">

            <br />
            &nbsp;
        </td>
    </tr>

    <tr>
        <td colspan="2" style="text-align: center">
            <br />
            &nbsp;
            <table width="100%" id="tbnotification" class="Stripy" style="display:block;">
            <tr>
                <tr>
                <td colspan="2" style="text-align: center">
                <asp:Label ID="tbnotif" runat="server" ReadOnly="True" Text="" >
                </asp:Label>
                </td>
                </tr>
               <tr>
               <td>

                <asp:GridView ID="gwreportpub" runat="server" CellPadding="5" BorderStyle="Solid" OnRowDataBound="coloraRighe" AllowPaging="true" PageSize="15" OnPageIndexChanging="GridView1_PageIndexChanging" style="border: 1px solid black;">
                 </asp:gridview>
               </td>
               </tr>
            </tr>
        </table>
        </td>
    </tr>


</table>
</form>
<script type="text/javascript"> 
    var dpck_1 = new DatePicker({ relative: 'txtSchedDate', language: 'it' });
</script>

4

1 に答える 1

0

OKはJavaで外部クライアントを作成し、aspxページ内でWebサービスを呼び出すためにこれを行った後、Webサービスを呼び出すjarを作成しました:

       System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.StartInfo.RedirectStandardOutput = true;
        proc.StartInfo.RedirectStandardError = true;
        proc.StartInfo.UseShellExecute = false;
        proc.StartInfo.FileName = "\"" + System.Web.HttpContext.Current.Server.MapPath(".") + "\\"  + "ConsoleApp.jar" + "\"" ;

        if(datarepo != "")
        proc.StartInfo.Arguments = "\""+connectionString +"\"" + " " +"\"" +reportname+"\""  + " " +"\"" +datarepo+"\""  + " " +"\"" +opco+"\""  + " " + "\"" +ambienteParm+"\"";
        else
        proc.StartInfo.Arguments = "\""+connectionString +"\"" + " " +"\"" +reportname+"\""  + " " +"\"" + "\""  + " " +"\"" +opco+"\""  + " " + "\"" +ambienteParm+"\"";

        proc.Start();
        proc.WaitForExit();
        //string result = proc.StandardOutput.ReadToEnd();
        //Response.Write(result + " - "  + proc.ExitCode);
        proc.Close();

みんなにthxs。

于 2013-02-12T09:03:31.567 に答える