【问题标题】:C# Web Reference and PHPC# Web 参考和 PHP
【发布时间】:2010-05-20 00:10:16
【问题描述】:

我正在尝试从我的 C# 应用程序调用 Web 服务(用 PHP 创建)。我已经在 Visual Studios 中成功添加了 Web 引用,但是我无法确切知道如何调用对 Web 服务的调用。我一直在关注本教程:http://sanity-free.org/article25.html 但是,当我尝试编译时,我得到一个“找不到类型或命名空间名称‘SimpleService’”。我的 C# 代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace inVision_OCR
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void translateButton_Click(object sender, EventArgs e)
        {
            // We need to snap the image here somehow . . .

            // Open up the image and read its contents into a string
            FileStream file = new FileStream("\\Hard Disk\\ocr_images\\test.jpg",     FileMode.Open);
            StreamReader sr = new StreamReader(file);
            string s = sr.ReadToEnd();
            sr.Close();

            // Using SOAP, pass this message to our development server
            SimpleService svc = new SimpleService();
            string s1 = svc.getOCR("test");
            MessageBox.Show(s);
        }
    }
}

【问题讨论】:

    标签: c# .net visual-studio web-services


    【解决方案1】:

    SimpleService 可能位于不同的命名空间中,请查看您添加的 Web 引用的属性并查看正在生成代理类 SimpleService 的命名空间,然后在您的代码中添加一条 using 语句来引用该命名空间。

    【讨论】:

    • 我很早就得出了这个结论。但是,似乎无论我做什么,我都无法让命名空间正确。我在哪里可以找到这些信息?我使用对象浏览器查看我的命名空间,但没有提到 SimpleService。
    猜你喜欢
    • 2010-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-23
    相关资源
    最近更新 更多