我试图将对象参数作为JSON格式传递给WCF restful service。
像这样的服务合同代码;
<system.serviceModel>
<services>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
我的web.config文件就像这样;
@IBAction func valueChanged1(_ sender: UISlider) {
var imageName : String = "Image.png"
switch (sender.value)
{
case 0:
print("zero")
imageName = "yyyy.png"
case 1:
print("one")
imageName = "zzzz.png"
case 2:
print("two")
imageName = "aaaa.png"
default:
print("Integer out of range")
}
if let image = UIImage(named:imageName) {
scaleImage.image = image
}
}
当我尝试使用&#34; http://localhost/serviceurl/xml/123&#34;网址,服务返回&#34;方法不允许&#34;错误信息。
答案 0 :(得分:0)
我解决了。我必须从<ProtocolMapping>
文件中删除<ServiceHostingEnvironment>
和web.config
标记。
现在它的工作正常。