如何在WCF服务URL中传递电子邮件ID [英] how to pass email id in wcf service url

查看:90
本文介绍了如何在WCF服务URL中传递电子邮件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们已经编写了使用wcf技术获取成员psw的代码,并显示了json代码,如下所示

service1.svc.cs代码
---------------------

Hi,

We have written code for fetching member psw using wcf technology with json code shown below

service1.svc.cs code
---------------------

public string GetMemberPassword(string surname,string email)
        {
           
                string result = cl.GetMemberPassword(surname, email);
                return result;

        }




和Iservice1.cs代码
--------------------------




and Iservice1.cs code
--------------------------

[OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetMemberPassword/{surname}/{email}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        string GetMemberPassword(string surname, string email);



问题是当我们键入url http://localhost:2330/Service1.svc/GetMemberPassword/srini/srini@gmail.com [ ^ ]

它给出了错误找不到资源.即http 404"
我们如何在wcf服务网址中传递电子邮件ID,请任何人帮助我们


问候
Sangamesh Arali



Problem is when we type url http://localhost:2330/Service1.svc/GetMemberPassword/srini/srini@gmail.com[^]

it is giving error " The resource cannot be found. that is http 404"
how we can pass email id in wcf service url please anybody help out us


Regards
Sangamesh Arali

推荐答案

问题最有可能与您用来提供文件的Web服务器有关.卡西尼岛已知URL中存在多个点问题.您可以通过切换到IIS Express轻松解决此问题.我刚刚写了一篇关于如何做到这一点的文章.只需几分钟(只需阅读开头的几节-其余只是高级内容),我认为它将解决您的问题.

这是我的文章的链接:

使用IIS Express简化Web开发 [ ^ ]

这是指向有关您的问题的堆栈溢出问题的链接:

http://stackoverflow.com/questions/8491159/email-address-as-part-of-a-wcf-data-service-querystring [
The problem is most likely with the web server that you are using to serve up the files. Cassini is known to have a problem with multiple dots in the URL. You can easily resolve this by switching to IIS Express. I just wrote an article on how to do that. It only takes a couple minutes (just read the opening couple sections - the rest is just advanced stuff) and I think it will fix your problem.

Here is a link to my article:

Make Web Development Easier with IIS Express[^]

And here is a link to the Stack Overflow question that talks about your issue:

http://stackoverflow.com/questions/8491159/email-address-as-part-of-a-wcf-data-service-querystring[^]


这可能无济于事,Tim的建议是很好,但有时您可能需要实际修改传递给WCF服务的HTTP标头.然后,您可以检查标题并获取自定义信息,例如电子邮件地址.

有趣的文章是
在WCF 4呼叫中添加自定义消息标题 [ ^ ]

另一种方法(但可能是一种糟糕但肮脏的方法)是替换所有".电子邮件中带有字符〜"(花体)的点(点),然后在服务中将〜"(花体)替换为.".同样,这些方法可能不是最佳实践",但是有一些方法可以给猫皮!!!!
This probably wont help and the suggestions by Tim is good, but sometimes you may want to actually modify the HTTP headers passed to the WCF service. You could then inspect the headers and obtain custom information such as email addresses.

An interesting article is Add Custom Message Header in WCF 4 Calls[^]

Another way (but probably a poor but dirty way) would be to replace all "." (dots) in the email with the character "~" (squiggle) and then in the service replace the "~" (squiggle) with "."''s. Again these approaches are probably not "best practice" but there are ways to skin a cat!!!


这篇关于如何在WCF服务URL中传递电子邮件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆