httpWebRequest调用wcf服务时url出现问题
当我手动调用 wcf 服务时,我应该在 url 位置输入什么:
HttpWebRequest httpWebRequest = WebRequest.Create(url)as HttpWebRequest;
应该有我的 svc 文件的 url
http://localhost/service/LMTService.svc
或 wsdl
http://localhost/service/LMTService.svc?wsdl
或服务操作的 url 吗?
http://localhost/service/LMTService.svc/soap/GetSerializedSoapData
When I call manually wcf service what should I type in url place :
HttpWebRequest httpWebRequest = WebRequest.Create(url)as HttpWebRequest;
should be there url to my svc file
http://localhost/service/LMTService.svc
or wsdl
http://localhost/service/LMTService.svc?wsdl
or url to service action ?
http://localhost/service/LMTService.svc/soap/GetSerializedSoapData
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于端点的绑定。如果使用 SOAP 绑定(即
basicHttpBinding
、wsHttpBinding
等),请求 URI 应为端点 地址(而不是服务地址) 。此外,在某些 SOAP 版本(例如basicHttpBinding
中使用的 SOAP11)中,您需要将操作指定为 HTTP 标头。如果您使用webHttpBinding
(具有webHttp
行为),则地址是端点的地址加上操作的 UriTemplate(默认情况下只是方法名称)你想打电话。下面的代码显示了一个基于
HttpWebRequest
的请求被发送到两个端点,一个使用BasicHttpBinding
,一个使用WebHttpBinding
。It depends on the binding of the endpoint. If using a SOAP binding (i.e.,
basicHttpBinding
,wsHttpBinding
, etc), the request URI should be the endpoint address (not the service address). Also, in some SOAP versions (such as SOAP11, used inbasicHttpBinding
), you need to specify the action as a HTTP header. If you're usingwebHttpBinding
(withwebHttp
behavior) the address is the address of the endpoint, plus the UriTemplate (which by default is just the method name) of the operation you want to call.The code below shows a
HttpWebRequest
-based request being sent to two endpoints, a one usingBasicHttpBinding
, one usingWebHttpBinding
.