急阿!如何调用WebService

sc650125 2009-08-21 02:01:38
我就在本地写了个webservice,用IIS进行建站名称webservice,可以浏览它和调用方法,
然后又在本地建立了个windows窗口,添加服务引用后,怎么调用里头的方法阿?
...全文
731 30 打赏 收藏 转发到动态 举报
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
ligongruangao 2010-07-07
  • 打赏
  • 举报
回复
呀哦~~ 得解~
谢谢~

sophia__rp 2010-03-01
  • 打赏
  • 举报
回复
呀哦~~ 得解~
谢谢~
羽毛之家 2010-02-25
  • 打赏
  • 举报
回复
这只是一个版本的问题,两个都可以用的
suners 2009-08-21
  • 打赏
  • 举报
回复
呵呵 上面看都说了
xzq686 2009-08-21
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 sc650125 的回复:]
楼上的再问下看HelloWorldRequest和HelloWorldRequest1是啥意思啊?
[/Quote]

呵..那是引用WEbService生成的代理类里面的东西..不用管他们..
xzq686 2009-08-21
  • 打赏
  • 举报
回复
我记得我碰到过这事..是因为引用了两次WebService..
如果是你删除原来的再引用就没事..
sc650125 2009-08-21
  • 打赏
  • 举报
回复
楼上的再问下看HelloWorldRequest和HelloWorldRequest1是啥意思啊?
xzq686 2009-08-21
  • 打赏
  • 举报
回复
可能是你的WCF本身有点问题吧..可能是你改动过什么东西..
不过没事..删除没用的就行.
xzq686 2009-08-21
  • 打赏
  • 举报
回复
嗯..没关系..你试试..自动生成的有时也会因为某些原因有问题..
试试下面的方法
<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删除..只留下面那个..应该有一个是不正确的..
不行.就把下面的删除..留上面的..
sc650125 2009-08-21
  • 打赏
  • 举报
回复
但是为什么会自动生成俩个啊.晕死了
sc650125 2009-08-21
  • 打赏
  • 举报
回复
好了!就是这个问题!写了俩个.
xzq686 2009-08-21
  • 打赏
  • 举报
回复
<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删除..只留下面那个..应该有一个是不正确的..
不行.就把下面的删除..留上面的..
sc650125 2009-08-21
  • 打赏
  • 举报
回复
那是自动生成的,我没有动过啊
xzq686 2009-08-21
  • 打赏
  • 举报
回复
<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>都有用吗?
是引用的时候自动生成的吗?你可以先把里面的内容清空..再重新引用一下..看行不
sc650125 2009-08-21
  • 打赏
  • 举报
回复
<?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>
sc650125 2009-08-21
  • 打赏
  • 举报
回复
就是运行后显示:无法加载协定为“ServiceReference.Service1Soap”的终结点配置,因为找到了协定的多个终结点配置.请按名称指示首选的终结点配置
xzq686 2009-08-21
  • 打赏
  • 举报
回复
能贴出来客户端调用的App.Config吗?
xzq686 2009-08-21
  • 打赏
  • 举报
回复

<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.
看你的提示..不只一个..
kamboo 2009-08-21
  • 打赏
  • 举报
回复
我平时就是这样用的,没问题啊。
你是实例化不了里面的类还是调用方法出错呢?
migercai 2009-08-21
  • 打赏
  • 举报
回复
一般可以点出来就没有什么问题的
看下你写的webservice共享没有(每个方法前面加上 [*******])具体的什么忘记了
加载更多回复(10)

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧