[英]How can I call my WCF service from browser?
I'm writing a webservice that is suppose to save json two json strings to DB. 我正在写一个Web服务,假设该服务将json两个json字符串保存到DB。 I can invoke it with sope UI and WCF Test Client but I can't call it from my browser.
我可以使用sope UI和WCF Test Client调用它,但不能从浏览器中调用它。 Is there some way to do that?
有什么办法吗?
The service will initially be used by android app and I have tried calling from it with out any luck. 该服务最初将由android应用程序使用,我尝试从中调用时没有任何运气。
Here is the interface of my service: 这是我的服务界面:
[ServiceContract]
public interface IRService
{
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "SaveCallResults?callInfo={callInfo}&testInfo={testInfo}")]
string SaveCallResults(string callInfo, string testInfo);
}
And here is my web.config 这是我的web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_RService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<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>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"
multipleSiteBindingsEnabled="true" />
<services>
<!-- causing error -->
<!--<service name="NovaRoadRunnerWS.RService" behaviorConfiguration="ServiceBehaviour" >
<endpoint address="" binding="webHttpBinding" contract="NovaRoadRunnerWS.IRService" behaviorConfiguration="web" >
</endpoint>
</service>-->
</services>
There are several errors in the web.config: web.config中有几个错误:
There is no service behavior named ServiceBehaviour behaviorConfiguration="ServiceBehaviour"
没有名为ServiceBehaviour
behaviorConfiguration="ServiceBehaviour"
服务行为
There is no endpoint behavior named web: behaviorConfiguration="web"
没有名为web的终结点行为:
behaviorConfiguration="web"
No name was given to the serviceBehaviors section: <behavior name="">
没有给serviceBehaviors部分
<behavior name="">
: <behavior name="">
I made the following change to fix the error: 我进行了以下更改以修复错误:
<behaviors>
<serviceBehaviors>
<behavior name="web">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
and 和
<services>
<service name="NovaRoadRunnerWS.RService" behaviorConfiguration="web" >
<endpoint address="" binding="webHttpBinding" contract="NovaRoadRunnerWS.IRService" >
</endpoint>
</service>
</services>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.