none
Call Web Service, Pass Value to It ( a way to integrate Gemini with Vault.) RRS feed

  • 问题

  • Hi, to everyone.
    I am a newbie to creating a C# coding applying inside .aspx file .
    I did faced a lot of problem while i doing a way to integrate Gemini with Vault.

    Now the situation is, i need to pass value from software name --> Vault Client to another software with name --> Gemini
    Both of their data were stored seperately into different database.
    Now i would  like to  create a .aspx file which will be called by the IIS i create name Fogbugz .

    Below is the source should be worked. However, due to the version of Gemini changed, the method to be used i need to change.

    http://gemini.countersoft.com/issue/ViewIssue.aspx?ID=470&PROJID=2


    I am creating a aspx file with following code:

    <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:SimSun;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->

    <% @ Import Namespace ="System" %>

    <% @ Import Namespace ="System.Net" %>

    <% @ Import Namespace ="System.IO" %>

     

    <% @ Page Language ="c#" Debug ="true" %>

     

     

    <%

     

    string ixBug;

    string sFile;

    string sPrev;

    string sNew;

    string url;

    string vaultUrl;

    string reposNumber;

    string pathToFile;

    string fileName;

     

    ixBug = Request.QueryString["ixBug" ];

    sFile = Request.QueryString["sFile" ];

    sPrev = Request.QueryString["sPrev" ];

    sNew = Request.QueryString["sNew" ];

     

    /*reposNumber = Left(sFile, Instr(sFile, "$") - 1);

    pathToFile = Right(sFile, Len(sFile) - Instr(sFile, "$") + 1);

    fileName = Right(sFile, Len(sFile) - InStrRev(sFile, "/"));

     

    vaultUrl = "http://localhost/VaultService/VaultWeb/GetFile.aspx?repid=" & reposNumber & "&path=" & pathToFile & "&version=" & sNew;

      */

    /*'url = "http://localhost/gemini/sc/AddSCFile.aspx?ii=" & ixBug & "&fn=" & fileName & "&scr=" & Server.UrlEncode(vaultUrl) & "&fp=" & pathToFile

     

    'Response.Redirect(url)

    'Response.Write(url)

      */

    Response.Write("test" );

     

     

        string soap = @"<?xml version=""1.0"" encoding=""utf-8""?>

    <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""

       xmlns:xsd=""http://www.w3.org/2001/XMLSchema""

       xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">

      <soap:Body>

        <CreateSourceControlFile xmlns=""http://syleetemp/gemini/webservices/"">

          <data>

     

            <IssueID>32</IssueID>

            <FileName>whatever</FileName>

            <FilePath>whateverrr</FilePath>

            <SourceControlRepository>Vault Server</SourceControlRepository>

          </data>

        </CreateSourceControlFile>

      </soap:Body>

    </soap:Envelope>" ;

        HttpWebRequest req = (HttpWebRequest )WebRequest .Create("http://localhost/Gemini/webservices/IssuesWS.asmx/CreateSourceControlFile" );

        req.Headers.Add("SOAPAction" , "\"http://tempuri.org/Register\"" );

        req.ContentType = "text/xml;charset=\"utf-8\"" ;

        req.Accept = "text/xml" ;

        req.Method = "POST" ;

     

        using (Stream stm = req.GetRequestStream())

        {

            using (StreamWriter stmw = new StreamWriter (stm))

            {

                stmw.Write(soap);

            }

        }

     

        WebResponse response = req.GetResponse();

     

        Stream responseStream = response.GetResponseStream();

     

    %>




    But after i execute it inside IIS, it show error of

    The remote server returned an error: (500) Internal Server Error.

    Server Error in '/FogBugz' Application.

    The remote server returned an error: (500) Internal Server Error.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

    Source Error:

    Line 67:     }
    Line 68: 
    Line 69:     WebResponse response = req.GetResponse();
    
    Line 70: 
    Line 71:     Stream responseStream = response.GetResponseStream();



    Is any professional can teach me? I am helpless now... Thank you a lot..
    Appreciate from bottom of my heart..

    Regards, Jim
    2009年4月3日 9:35

答案

  •  HttpWebRequest req = (HttpWebRequest )WebRequest .Create("http://localhost/Gemini/webservices/IssuesWS.asmx/CreateSourceControlFile" );

        req.Headers.Add("SOAPAction" , "\"http://tempuri.org/Register\"" );

        req.ContentType = "text/xml;charset=\"utf-8\"" ;

        req.Accept = "text/xml" ;

        req.Method = "POST" ;

    Hello,

    It seems that you want to call a webservice by the above method.
    I think it's much better to call webservice by adding a web reference and then instantiate a proxy class to call that method you want.
    You can visit the following website to know how to call a webservice and then try it again.
    http://money.makoyskie.com/2009/02/how-to-call-web-service-in-cnet.html
    Microsoft Online Community Support
    2009年4月8日 3:48

全部回复

  • Hi, Is anybody can help me?
    2009年4月7日 2:33
  •  HttpWebRequest req = (HttpWebRequest )WebRequest .Create("http://localhost/Gemini/webservices/IssuesWS.asmx/CreateSourceControlFile" );

        req.Headers.Add("SOAPAction" , "\"http://tempuri.org/Register\"" );

        req.ContentType = "text/xml;charset=\"utf-8\"" ;

        req.Accept = "text/xml" ;

        req.Method = "POST" ;

    Hello,

    It seems that you want to call a webservice by the above method.
    I think it's much better to call webservice by adding a web reference and then instantiate a proxy class to call that method you want.
    You can visit the following website to know how to call a webservice and then try it again.
    http://money.makoyskie.com/2009/02/how-to-call-web-service-in-cnet.html
    Microsoft Online Community Support
    2009年4月8日 3:48