我就在本地写了个webservice,用IIS进行建站名称webservice,可以浏览它和调用方法,
然后又在本地建立了个windows窗口,添加服务引用后,怎么调用里头的方法阿?

解决方案 »

  1.   

    添加web引用
    或者用ajax调用
      

  2.   

    点出来了的,说是无法加载协定为“ServiceReference.Service1Soap”的终结点配置
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms; namespace Wclient
    {
        public partial class Form1 : Form
        {
            private ServiceReference.Service1SoapClient Client;
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {        }        private void button1_Click(object sender, EventArgs e)
            {
                Client = new ServiceReference.Service1SoapClient();
                 string name = Client.showtime();  
                textBox1.Text=name; 
            }
        }
    }
      

  3.   

    首先在在bin文件夹下面添加服务,在到类里面引入命名空间。
    接着就实例化webservice,实例名。具体的方法....完毕..........
      

  4.   

    我引用后.默认命名空间为localhost
    调用代码如下:   private void button1_Click(object sender, EventArgs e)
            {
                new localhost.Service1().HelloWorld();
            }
      

  5.   

    WCF呀.
    你的客户端加App.config了吗?
      

  6.   

    既然已经添加了引用,那就可以像用本地的DLL那样用啦.
    Web引用名.命名空间.类名 cc=new Web引用名.命名空间.类名(参数)
    cc.方法(参数)
      

  7.   

    我的ServiceReference里有好多个类的HelloWorldRequest,HelloWorldRequest1,HelloWorldResponse,HelloWorldResponse1,Service1HttpGetClient..
      

  8.   

    一般可以点出来就没有什么问题的
    看下你写的webservice共享没有(每个方法前面加上 [*******])具体的什么忘记了
      

  9.   


    <client>
          <endpoint address="http://localhost/WcfWebService/WcfServiceLibrary/Service1/"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService11"
            contract="ServiceReference1.IService1" name="WSHttpBinding_IService11">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
        </client>看你的App.Config中这个Client结点下..有几个endpoint.
    看你的提示..不只一个..
      

  10.   

    能贴出来客户端调用的App.Config吗?
      

  11.   

    就是运行后显示:无法加载协定为“ServiceReference.Service1Soap”的终结点配置,因为找到了协定的多个终结点配置.请按名称指示首选的终结点配置
      

  12.   

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00"
                        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                </basicHttpBinding>
                <customBinding>
                    <binding name="Service1Soap12">
                        <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                            messageVersion="Soap12" writeEncoding="utf-8">
                            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        </textMessageEncoding>
                        <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                            maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                            keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                            realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                            useDefaultWebProxy="true" />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:8000/Service1.asmx" binding="basicHttpBinding"
                    bindingConfiguration="Service1Soap" contract="ServiceReference.Service1Soap"
                    name="Service1Soap" />
                <endpoint address="http://localhost:8000/Service1.asmx" binding="customBinding"
                    bindingConfiguration="Service1Soap12" contract="ServiceReference.Service1Soap"
                    name="Service1Soap12" />
            </client>
        </system.serviceModel>
    </configuration>
      

  13.   

         <client> 
                <endpoint address="http://localhost:8000/Service1.asmx" binding="basicHttpBinding" 
                    bindingConfiguration="Service1Soap" contract="ServiceReference.Service1Soap" 
                    name="Service1Soap" /> 
                <endpoint address="http://localhost:8000/Service1.asmx" binding="customBinding" 
                    bindingConfiguration="Service1Soap12" contract="ServiceReference.Service1Soap" 
                    name="Service1Soap12" /> 
            </client> 
    这两个<endpoint>都有用吗?
    是引用的时候自动生成的吗?你可以先把里面的内容清空..再重新引用一下..看行不
      

  14.   

     <client> 
                <endpoint address="http://localhost:8000/Service1.asmx" binding="basicHttpBinding" 
                    bindingConfiguration="Service1Soap" contract="ServiceReference.Service1Soap" 
                    name="Service1Soap" /> 
                <endpoint address="http://localhost:8000/Service1.asmx" binding="customBinding" 
                    bindingConfiguration="Service1Soap12" contract="ServiceReference.Service1Soap" 
                    name="Service1Soap12" /> 
            </client> 
    把上面的endpoint删除..只留下面那个..应该有一个是不正确的..
    不行.就把下面的删除..留上面的..
      

  15.   

    嗯..没关系..你试试..自动生成的有时也会因为某些原因有问题..
    试试下面的方法
    <client> 
                <endpoint address="http://localhost:8000/Service1.asmx" binding="basicHttpBinding" 
                    bindingConfiguration="Service1Soap" contract="ServiceReference.Service1Soap" 
                    name="Service1Soap" /> 
                <endpoint address="http://localhost:8000/Service1.asmx" binding="customBinding" 
                    bindingConfiguration="Service1Soap12" contract="ServiceReference.Service1Soap" 
                    name="Service1Soap12" /> 
            </client> 
    把上面的endpoint删除..只留下面那个..应该有一个是不正确的.. 
    不行.就把下面的删除..留上面的..
      

  16.   

    可能是你的WCF本身有点问题吧..可能是你改动过什么东西..
    不过没事..删除没用的就行.
      

  17.   

    楼上的再问下看HelloWorldRequest和HelloWorldRequest1是啥意思啊?
      

  18.   

    我记得我碰到过这事..是因为引用了两次WebService..
    如果是你删除原来的再引用就没事..
      

  19.   


    呵..那是引用WEbService生成的代理类里面的东西..不用管他们..