tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
1
ZUGRIFFE
459
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    Castor_Troy Castor_Troy ist offline Mitglied
    Registriert seit
    Oct 2007
    Beiträge
    11
    Hi bin totaler .Net wollte mich aber an das Thema Webservices mal ran wagen.

    Ich entwickle in Visual Studio 2008 und hab keinen IIS installiert weil beim VS2008 anscheinend ein kleiner IIS mitdabei ist zumindenstens kompiliert er und zeigt es im Browser gleich fachgerecht an.

    So nun zu meinem Problem:
    - Habe ein Projekt FirstService welches ein Asp.Net Webservice ist (asmx). Es beinhaltet nur 2 Methoden HelloWorld und Add. Die HP kann per VS2008 sauber dargestellt werden.

    - Will nun per Client auf diese Methoden zugreifen, bekomme das aber nie hin weil ich das Objekt für den WebService nie aufrufen kann (irgendein Problem mit dem Namespace)

    Müssen Client & Server im selben Projekt sein ? Muss man eine Referenz anlegen um darauf zugreifen zu können ? Brauch ich unbedingt einen IIS ? Würde der IIS 5.1 reichen ?


    Bin für jeden Tipp dankbar ......

    Service:

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Linq;
     
    namespace FirstService
    {
        /// <summary>
        /// Summary description for Service1
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        // [System.Web.Script.Services.ScriptService]
        public class Service1 : System.Web.Services.WebService
        {
     
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
     
            [WebMethod]
            public int Add(int a, int b)
            {
                return a + b;
            }
        }
    }

    WepApplication2:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    
    <%@ Page Language="C#" %>
      <script runat="server">
      void runSrvice_Click(Object sender, EventArgs e)
      {
          FirstService mySvc = new FirstService();
          Label1.Text = mySvc.SayHello();
          Label2.Text = mySvc.Add(Int32.Parse(txtNum1.Text),Int32.Parse(txtNum2.Text)).ToString();
      }
      </script>
      <html>
      <head>
      </head>
      <body>
      <form id="Form1" runat="server">
        <p>
            <em>First Number to Add </em>:
            <asp:TextBox id="txtNum1" runat="server"
                 Width="43px">4</asp:TextBox>
        </p>
        <p>
            <em>Second Number To Add </em>:
            <asp:TextBox id="txtNum2" runat="server"
                 Width="44px">5</asp:TextBox>
        </p>
        <p>
            <strong><u>Web Service Result -</u></strong>
        </p>
        <p>
            <em>Hello world Service</em> :
            <asp:Label id="Label1" runat="server"
                 Font-Underline="True">Label</asp:Label>
        </p>
        <p>
            <em>Add Service</em> :
            & <asp:Label id="Label2" runat="server"
                   Font-Underline="True">Label</asp:Label>
        </p>
        <p align="left">
            <asp:Button id="runSrvice" onclick="runSrvice_Click"
                 runat="server" Text="Execute"></asp:Button>
        </p>
      </form>
      </body>
      </html>
     

  2. #2
    Castor_Troy Castor_Troy ist offline Mitglied
    Registriert seit
    Oct 2007
    Beiträge
    11
    hab es teilweise selbst gecheckt: Hab eine Referenz anlegen können und nun ist das Objekt unter WebApplication2.localhost.Service1 zu finden

    Die Methoden mussten noch ausgebessert werden nun rennts zumindenstens mal
     

Ähnliche Themen

  1. Frage zu Namespace in XML Datei
    Von DarthShader im Forum XML Technologien
    Antworten: 2
    Letzter Beitrag: 24.10.10, 00:27
  2. Frage bzgl. SUM
    Von SantaCruze im Forum Relationale Datenbanksysteme
    Antworten: 2
    Letzter Beitrag: 11.02.07, 16:44
  3. frage bzgl, images
    Von Samuel im Forum Javascript & Ajax
    Antworten: 2
    Letzter Beitrag: 01.03.02, 16:16
  4. ´frage bzgl. clipping
    Von Samuel im Forum Javascript & Ajax
    Antworten: 3
    Letzter Beitrag: 19.02.02, 14:33
  5. frage bzgl. preloader...
    Von Montz im Forum Flash Plattform
    Antworten: 4
    Letzter Beitrag: 24.06.01, 11:01