在 https 上使用时,网络服务返回 404 ,否则它可以正常工作。设置如下......
的web.config:
<services>
<service name="WebAppSSL.astLogin">
<endpoint address=""
binding="webHttpBinding"
contract="WebAppSSL.astLogin" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
svc代码是......
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class astLogin
{
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
public string welcome(string name)
{
return "Hi " + name;
}
}
跟踪显示此消息......
<Description>Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found.</Description>
答案 0 :(得分:0)
如果有人在这里,这是供参考的......
解决方案是使用静态wsdl&amp; xsd文件;至少它对我有用。我的设置是......
最重要的:启用webservice跟踪; How to enable trace.
可以通过从VS Command执行svctraceviewer.exe
来查看跟踪文件;在那里你需要选择跟踪文件
如 web.config 文件中所述。
您需要确保SSL已链接到网站并已激活。 SSL
更改web.config;示例配置元素是......
<system.serviceModel>
<services>
<service name="WebAppSSL.astLogin" behaviorConfiguration="astLoginSrvcBehavior">
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="secureHttpBinding"
behaviorConfiguration="astLoginEpntBehavior"
contract="WebAppSSL.astLogin">
<identity>
<dns value="" />
</identity>
</endpoint>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="secureHttpBinding" crossDomainScriptAccessEnabled="true">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="astLoginEpntBehavior">
<webHttp faultExceptionEnabled="true" automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="astLoginSrvcBehavior">
<serviceMetadata
httpsGetEnabled="true"
externalMetadataLocation="astLogin.wsdl"
/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
在 web.config 文件中引用元素<serviceBehaviors><behavior><serviceMeradata>
,属性 externalMetadataLocation 将用于指向静态wsdl文件。对于大型应用程序来说,这是一个累人的过程,服务文件结构的任何变化都需要重复该服务的过程。
生成wsdl&amp; xsd文件:
运行您的应用程序以打开服务uri
'http://webapplication-domain-name/service-name.svc'
您将获得页面内容,如...
点击 svcutil.exe 链接,您将看到xml,如...
<wsdl:definitions name="astLogin" targetNamespace="http://tempuri.org/">
<wsdl:import namespace="" location="https://localhost/WebAppSSL/astLogin.svc?wsdl=wsdl0"/>
<wsdl:types/>
<wsdl:service name="astLogin"/>
</wsdl:definitions>
使用?wsdl 复制网址,即 https://localhost/WebAppSSL/astLogin.svc?wsdl = wsdl0 并粘贴到新标签或页面
您将获得WSDL文件,如...
<wsdl:definitions targetNamespace="">
<wsdl:types>
<xsd:schema targetNamespace="/Imports">
<xsd:import schemaLocation="https://localhost/WebAppSSL/astLogin.svc?xsd=xsd0"/>
<xsd:import schemaLocation="https://localhost/WebAppSSL/astLogin.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/><xsd:import schemaLocation="https://localhost/WebAppSSL/astLogin.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/WebAppSSL.Models"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="astLogin_DoWork_InputMessage">
<wsdl:part name="parameters" element="DoWork"/>
</wsdl:message>
<wsdl:message name="astLogin_DoWork_OutputMessage">
<wsdl:part name="parameters" element="DoWorkResponse"/>
</wsdl:message>
<wsdl:portType name="astLogin">
<wsdl:operation name="DoWork">
<wsdl:input wsaw:Action="urn:astLogin/DoWork" message="astLogin_DoWork_InputMessage"/>
<wsdl:output wsaw:Action="urn:astLogin/DoWorkResponse" message="astLogin_DoWork_OutputMessage"/>
</wsdl:operation>
</wsdl:definitions>
在WSDL文件中查找<xsd:import>
部分,复制schemaLocation
的网址并粘贴到新标签或页面
(您需要为所有导入执行此操作,但schemaLocation指的是 namespace =“http://schemas.microsoft.com/2003/10/Serialization/”对应用程序执行一次
XSD文件(当我说文件时,我的意思是你需要复制/粘贴或保存页面为filename.wsdl或filename.xsd)可能看起来像...
<xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/WebAppSSL.Models">
<xs:complexType name="Elogin">
<xs:sequence>
<xs:element minOccurs="0" name="CompanyReqAuthentication" type="xs:boolean"/>
<xs:element minOccurs="0" name="ErrorCode" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="ErrorMessage" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="TokenID" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="UserReqAuthentication" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Elogin" nillable="true" type="tns:Elogin"/>
</xs:schema>
现在您拥有WSDL和XSD文件。在这两个文件中,使用 https://localhost/WebAppSSL/ 替换'https://fqdn/'(对您而言会有所不同) 并非所有的XSD文件都会引用您的开发机器URL,原因是只有当底层函数引用时才会引用XSD 到数据交换的模型/类。
就是这样。
现金:
https://www.codeproject.com/Questions/166246/Error-There-was-no-endpoint-listening-at
http://www.mytechtip.com/2012/09/static-wsdl-with-imported-xml-schema-in.html