wcf问题集锦

1.处理程序“svc-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”

  1. HTTP 错误 404.3 - Not Found

    由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。

    解决办法:以管理员运行命令:C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i

  2.  HTTP 错误 500.21 - Internal Server Error 

    处理程序“svc-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”

    解决办法:

    原因:在安装Framework v4.0之后,再启用IIS,导致Framework没有完全安装

    解决:开始->所有程序->附件->鼠标右键点击“命令提示符”->以管理员身份运行->%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

    如果还不行,可检查IIS的应用程序池,是否使用集成模式,如果不是则改成集成模式

2.WCF Add Service Reference gotcha with Windows Server

We recently switched from developing in Vista to Windows Server 2003. Someone had the bright idea that we should develop in the same environment the application is going to be hosted on. Go figure.

What that meant is that you run into wierd issues like this one. When trying to add a Service Reference to a WCF service hosted under IIS you keep getting this 'Add Service Reference Error':

Metadata contains a reference that cannot be resolved: 'http://merill/Services.Host/ClientProfile.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://merill/Services.Host/ClientProfile.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://localhost/Services.Host/ClientProfile.svc'.
Metadata contains a reference that cannot be resolved: 'http://localhost/Services.Host/ClientProfile.svc'.
If the service is defined in the current solution, try building the solution and adding the service reference again.

The key part of this message is the reference to the downloading of the xsd. When I tried accessing the .svc url in a browser it worked fine, but trying to access the .svc?xsd=xsd0 brings up the generic 'cannot display webpage' message.

When you unleash your weapon (Process Monitor) on the csc.exe process (this is the compiler generating the xsd) you'll realise that the IIS identity IIS_WPG does not have access to the Windows\Temp folder. Give enough rights to the folder and viola problemo solved.

Reference:http://merill.net/2008/04/wcf-add-service-reference-gotcha-with-windows-server/

3. gsoap 调用 WCF 415 错误 (soap: 非托管c++ 客户端的开发(gsoap)

问题: gsoap调用 WCF 返回错误415  unsported media type

我要wireshark抓包,发现WCF返回: Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.

分析: WCF server端 basicHttpBinding 只支持 soap 1.1,而client端 gsoap生成的客户端代码 默认为 soap1.2

解决:gsoap 的soapcpp2的参数 -1 为soap 1.1   -2为soap1.2

 例如:D:\GSoap\gsoap-2.8\gsoap\bin\win32\soapcpp2 -i -x -d D:\GSoap\recycle -C D:\GSoap\recycle.h -I D:\GSoap\gsoap-2.8\gsoap\import -1

4.C++的gsoap客户端与基于WCF的C#服务端Web Service交互的问题

服务端使用SOAP 1.2,在Windows下用C#开发;客户端使用跨平台的gsoap开发包(版本为2.7.15),在Linux下使用C++开发。

(1)证书问题。

当Web Service使用SSL/HTTPS进行通信时,跨平台的证书问题怎么处理?如果你对证书非常了解,那么没问题,你可以在十几分钟内就搞定它。但是如果你根本就不知道”自签名的证书“是怎么一回事的话,那就有得受了。证书还牵涉到你所使用的SOAP开发包,因为不同的开发包要求使用的证书格式也不同。例如,gsoap就要用pem格式的证书文件。这个文件怎么得到?自签名的证书又是怎么一回事?它跟Web Service有什么关系?这个真不是一两句话就可以说得清楚的,恐怕要从”Web Service是什么“来说起了。但是我也不可能长篇大论地打几万字上来,所以有些基础的概念还是请您自己挪步google吧。

文章来源:http://www.codelast.com/

(2)SOAP 1.1/1.2的兼容性问题。

当服务端和客户端使用的SOAP版本不同时,能不能配合上?我没有试过,当然,我的直接想法就是:服务端用哪个版本,客户端就用哪个版本的SOAP,所以事先双方最好确定一下各自的版本。但是就算是同一版本,由于服务端和客户端不是同一平台的,也有可能出问题。例如,我的Web Service服务端使用SOAP 1.2,我使用gsoap做的client死活就是无法调用它。这个问题还没解决,但是我说一下其中的几个问题。

一是HTTP header中的SOAPAction的问题。使用gsoap开发,可以生成调试信息,把发送的HTTP头信息及XML数据保存到文件中(默认文件名为“SENT.log”,文件名可以在运行时(runtime)来修改),打开它,可以看到有用的调试信息,以帮助你确定问题所在。gsoap 2.7.15的pdf文档里写得很清楚,soapcpp2默认生成的代理类是SOAP 1.1的,如果要生成SOAP 1.2的,请使用-2参数,但是在某个国外的技术论坛中,我看到一些人说-2参数有时候是无效的(这种说法未经证实),到底是SOAP 1.1还是SOAP 1.2,其实是由.nsmap文件来控制的。.nsmap文件保存的是XML命名空间表,该文件是soapcpp2编译器生成的。

你可能感兴趣的:(WCF)