我们有一个内部IIS Web服务器和外部IIS Web服务器。当我发布使用Web服务的同一Web应用程序时,在两个服务器中,我都会发现WebService类未定义的错误。
下面是我的ASPX页面中的代码
<asp:ScriptManager ID="sm_orderset" runat="server">
<Services>
<asp:ServiceReference Path="OrdersetService.svc" />
</Services>
</asp:ScriptManager>
这是JS
中的调用<script type="text/javascript">
//Ajax functions for retrieving and displaying comments
function getComments(componentid) {
OrdersetService.getComments(componentid, onSuccess);
}
</script>
呼叫该函数什么都不做。这是我在调试中找到的
脚本:5009:'OrderSeservice'是未定义的
文件:jsfunctions.js,行:8,列:5
发现问题是由于第二个需要SSL绑定的服务器。更改了我在WebConfig中的服务配置以获取结果。
这是我的webconfig
的最终结果 <system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="Online_Power_Plan.OrdersetServiceAspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="Online_Power_Plan.OrdersetService">
<endpoint address="" behaviorConfiguration="Online_Power_Plan.OrdersetServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="secureHttpBinding" contract="Online_Power_Plan.OrdersetService"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>