我就在本地写了个webservice,用IIS进行建站名称webservice,可以浏览它和调用方法,
然后又在本地建立了个windows窗口,添加服务引用后,怎么调用里头的方法阿?
然后又在本地建立了个windows窗口,添加服务引用后,怎么调用里头的方法阿?
解决方案 »
- 无法启动多个Windows服务,只能启动ServiceBase数组中第一个服务
- webserivce如何返回这样格式
- Access数据库导入Sql server 2005数据库
- linq to dataset 如何将查询结果结果转换成DataRowCollections
- 用OWC时传入正值,怎么会出现负值的曲线图呢??????(200分求解,UP有分)
- 头一次做web开发,问个简单的问题,怎么做移动字幕啊?
- 托盘的问题,单击托盘菜单中的命令之后窗体不显示。
- 求一段运用正则完整C#代码
- 最新发现,一个可以免费下载视频教程的网站
- 【C#】如何让两个listBox同时多选?
- 开源的皮肤控件
- 祭奠7.7,重分悬赏代码(200)
或者用ajax调用
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;
}
}
}
接着就实例化webservice,实例名。具体的方法....完毕..........
调用代码如下: private void button1_Click(object sender, EventArgs e)
{
new localhost.Service1().HelloWorld();
}
你的客户端加App.config了吗?
Web引用名.命名空间.类名 cc=new Web引用名.命名空间.类名(参数)
cc.方法(参数)
看下你写的webservice共享没有(每个方法前面加上 [*******])具体的什么忘记了
<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.
看你的提示..不只一个..
<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>
<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>都有用吗?
是引用的时候自动生成的吗?你可以先把里面的内容清空..再重新引用一下..看行不
<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删除..只留下面那个..应该有一个是不正确的..
不行.就把下面的删除..留上面的..
试试下面的方法
<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删除..只留下面那个..应该有一个是不正确的..
不行.就把下面的删除..留上面的..
不过没事..删除没用的就行.
如果是你删除原来的再引用就没事..
呵..那是引用WEbService生成的代理类里面的东西..不用管他们..