首页 新闻 搜索 专区 学院

wcf rest service Post Submitted 请求因 HTTP 状态 405 失败: Method Not Allowed。

0
悬赏园豆:30 [待解决问题]

add web Reference 输入地址:http://localhost:50759/mPageService.svc/updateMessageTemplateJson_POST?category=Nurse&name=news service&description='this is your news service&subject=wcf webservice&content=Hi zSong

游览器显示“不允许此方法。”,“下载“http://localhost:50759/mPageService.svc/updateMessageTemplateJson_POST?category=Nurse&name=news service&description='this is your news service&subject=wcf webservice&content=Hi zSong”时出错。
请求因 HTTP 状态 405 失败: Method Not Allowed。
There was an error downloading 'http://localhost:50759/mPageService”

以下是代码ISERVER与config的代码:

ImPageService.cs

1 using System;
2  using System.Collections.Generic;
3  using System.Linq;
4  using System.Data;
5 using System.Runtime.Serialization;
6 using System.ServiceModel.Web;
7 using System.ServiceModel;
8 using System.Text;
9
10 namespace mPageService
11 {
12 // NOTE: If you change the interface name "ImPageService" here, you must also update the reference to "ImPageService" in Web.config.
13 [System.Web.Script.Services.ScriptService()]
14 [ServiceContract(Namespace = "", Name = "mPageService")]
15 public interface ImPageService
16 {
17 [OperationContract]
18 [WebInvoke(BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
19 void updateMessageTemplateJson_POST(string category, string name, string description, string subject, string content);
20 }

web.config

 

<authentication mode="Forms" />
<system.serviceModel>
<services>
<service behaviorConfiguration="mPageService.mPageServiceBehavior" name="mPageService.mPageService">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="AjaxBehavior" contract="mPageService.ImPageService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" listenUriMode="Explicit" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior name="mPageService.mPageServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript/> <!--<webHttp/>-->
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>

 

 

 希望哪位好心人帮我看呀,急急...

restService的主页 restService | 初学一级 | 园豆:170
提问于:2011-01-19 13:07
< >
分享
所有回答(3)
0

一般是地址错误了 点开wcf的那个help看看 http://url/help

听说读写 | 园豆:777 (小虾三级) | 2011-01-19 16:22
不是地址错误,我反复对过规范的一个URI命名规范,应该没问题!可以帮我看看吗? MSN:hlloaccp@live.cn
支持(0) 反对(0) restService | 园豆:170 (初学一级) | 2011-01-19 18:18
0

http://localhost:50759/mPageService.svc/mex

添加服务引用,而不是web引用。

Launcher | 园豆:45045 (高人七级) | 2011-01-19 21:55
添加服务引用,我不是很明白,可以写个简单的例子吗?
支持(0) 反对(0) restService | 园豆:170 (初学一级) | 2011-01-20 08:18
0

从你的配置文件上来看,你这个是一个需要在客户端添加Scriptmanager控件来调用ajax的enabled- ajax - wcf wservice,这样的service是不能再客户端通过添加应用的方式调用的,具体的调用方法你可以参考一下这个link http://archive.cnblogs.com/a/1934492/

dbms | 园豆:75 (初学一级) | 2011-04-15 15:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册