小编Mac*_*Mac的帖子

是否有任何理由不在通过http提供的页面上提供https内容?

我目前在只能通过https访问的域上提供图像内容.在通过http访问的页面上使用https路径提供图像的缺点是什么?有任何缓存注意事项吗?我正在使用HttpRuntime.Cache对象来存储从数据库中检索的绝对图像路径.

  • 我假设如果图像只能通过https访问,那么使用协议相对URL没有任何好处吗?

  • 有没有令人信服的理由为什么我应该设置一个单独的虚拟目录来通过http提供图像内容?

security https

13
推荐指数
1
解决办法
6965
查看次数

Web服务XML响应作为"text/plain"接收.(还有另一种内容类型错误.)

我正在尝试开发一个Web应用程序,使用WCF向Web服务提交一个简单的登录请求,但我不断收到"内容类型文本/响应消息的明文不匹配"错误,即使Web服务似乎正在返回有效的XML.

我已经回顾了有关此错误的数十篇类似的SO帖子,并排除了更常见的可能性:

  1. 我可以在响应中看到它不是一个Error页面(如这里所讨论的).
  2. 我似乎不具有绑定不匹配的问题(如讨论这里).我的应用程序和Web服务都使用SOAP 1.1,我指定了"basicHttpBinding".
  3. 我的错误消息中包含的响应似乎显示有效的XML,其中包含我想要的用户和响应变量.
  4. 我可以在Web服务日志文件中看到登录方法完全执行而不会抛出异常.
  5. 我将XML响应粘贴到W3Schools验证器中,没有错误.

还有什么可能导致我的错误,为什么这不被认为是有效的XML?

我正在为我的应用程序使用.Net 4.0和Visual Studio 2010,它在单独的服务器上与Java/Tomcat Web服务进行通信.

以下是我的登录代码的相关摘录:

AuthenticationServiceClient client = new AuthenticationServiceClient(strPortName, strURL);
client.Open();
UserCredentials credentials = new UserCredentials();
credentials.userName = TestUsername;
credentials.password = TestPassword;
LoginResponse response = client.login(credentials); // Using WCF.
Run Code Online (Sandbox Code Playgroud)

这是绑定在我的Web.Config中的样子:

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="AuthenticationServiceSoapBinding" />
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://mywebserviceurl"
      binding="basicHttpBinding" bindingConfiguration="AuthenticationServiceSoapBinding"
      contract="MyNamespace.AuthenticationService" name="AuthenticationServiceImplPort" />
  </client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

这是我的错误信息:

在"WebServiceURL"上测试与Web服务的连接时出错:System.ServiceModel.ProtocolException:响应消息的内容类型text/plain与绑定的内容类型(text/xml; charset = utf-8)不匹配.如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法.响应的前788个字节是:'

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<loginReponse xmlns="urn:xxxx">
<authKey>xxxx</authKey>
<authMetadata>
<IPaddress>https://MyWebApplicationURL</IPaddress>
<loginTimestamp>xxxx</loginTimestamp><levelOfAssurance>
<AuthMechanism>xxxx</AuthMechanism>
<VettingAssertion>xxxx</VettingAssertion>
</levelOfAssurance> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net wcf web-services

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net ×1

c# ×1

https ×1

security ×1

wcf ×1

web-services ×1