【问题标题】:invoke webservice from another PC从另一台 PC 调用 Web 服务
【发布时间】:2013-01-24 11:14:22
【问题描述】:

我有一个问题,您如何从另一台 PC 调用 Web 服务我在 Windows 7 中有一个使用 IIS 6.1 的 Web 服务,另一台 PC 在 Windows XP 中有一个 IIS 6,Web 服务使用 Web 应用程序在 localhost 中工作,现在唯一的事情是我正在尝试从另一台 PC 调用 Web 服务,但现在不知道该怎么做,我必须提到的一件事是我没有将 Visual Studio 用于我的 Web 服务和 Web 应用程序,我将所有代码写在一个文本块中并使用 Web 浏览器查看 Web 应用程序,所以问题是另一台 PC 的 Web 应用程序也将被写在一个文本块中,但我现在什至不知道如何调用。

当我从同一台 PC 调用时,我使用了 Web 服务中的下一个代码,这是一个简单的示例:

<%@ WebService language="C#" class="FirstService" %>
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Xml.Serialization;
    using System.Web.Services;
    [WebService(Namespace="http://localhost/MyWebServices2/")]
    public class FirstService : WebService
        {

        [WebMethod]
    public double[][] Size(int X_1,int Y_1)
    {
        double [][] dime =  new double [X_1][];
        for (int r=0;r  < X_1; r++)
       {
        dime[r] = new double[Y_1];
        }
    return dime;
        }

       }

Web 应用程序使用了下一个代码:

<script runat="server">

    void loadFile_Click(Object sender, EventArgs e)
    {
        int x1=0,y1=0;
        x1= Convert.ToInt32(txtNum1.Text);
        y1= Convert.ToInt32(txtNum2.Text);
        FirstService mySvc = new FirstService();
        mySvc.Tamano(x1,y1);
        }
 </script>  

是否需要更改我的代码的某些部分?或者所有的变化都来自另一台 PC 的 Web 应用程序?

【问题讨论】:

    标签: asp.net web-services web-applications iis-6


    【解决方案1】:

    您需要在 Web 服务代理对象上设置“Url”属性,“mySvc”指向 托管 Web 服务的计算机上的端点。

    示例 - mySvc.Url = "http://machine:80//service...

    请参阅参考文档 - Proxy reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-27
      • 2011-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多