最近项目需要通过JS调用一个自承载的服务,参见了JavaScript调用WCFService方法,可是例子是用IIS承载的,有两个问题
- 编写的时候需要加[WebInvoke]但是加上这个属性就得用.net framework 4,而win8自带的client profile就不行了;这个有别的方法吗?
- 用了.net framework4之后继续编辑,我在添加了WCF Service编译出的DLL之后提示”未能加载文件或程序集",但是这个程序集在运行目录下啊
详细的app.config
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:5021/JSDesktopService"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" />
</basicHttpBinding>
<customBinding>
<binding name="JsonMapper">
<webMessageEncoding webContentTypeMapperType="JSWCFTest.JsonContentTypeMapper, JsonContentTypeMapper, Version=1.0.0.0"></webMessageEncoding>
<httpTransport manualAddressing="true" />
</binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration="NewBehavior0" name="JSWCFTest.JSDesktopService">
<endpoint address="http://localhost:5021/JSDesktopService" binding="customBinding"
bindingConfiguration="JsonMapper" contract="JSWCFTest.IJSDesktopService" />
</service>
</services>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>