How to get a flat WSDL from a WCF serivce?

本文探讨了WCF服务中WSDL文件不完整的问题,并提供了两种解决方案:一是通过配置静态WSDL文件并调整服务行为;二是开发自定义行为来支持内联XSD,从而简化客户端的集成工作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I think most of you prefer to implement service port type  first while try to build a wcf service. That is ok, however, did you ever take the final stub class in your consideration, in the meanwhile you are coding a wcf service?

 As known, we can use ?WSDL to get wsdl displayed in IE. Most of time, we will get the following WSDL:

<wsdl:import namespace=http://services/ location=http://XXXX/Service.svc?wsdl=wsdl0 />

<wsdl:types />

Unfortunately, Schemas and Messages are missing. It will be a big impact to generate proxy class by wsdl.exe or access by SOAP UI.

At then, we have to query like http://XXXX/Service.svc?wsdl=wsdl0, http://XXXX/Service.svc?xsd=xsdn (n starts from 0) to get schemas and Messages.

If this service is large enough, you will find it will be a tough job.

 

Ok, what should we do now? I think we have two approaches:

1, facilitate a static wsdl file before developing services. and configure  <system.serviceModel> section like the following:

<services>

<!-- Replace the parameters below for your service implementation -->

   <service name="ServicePortType" behaviorConfiguration="ServiceBehavior" >

      <endpoint address="" binding="basicHttpBinding" bindingNamespace=http://service/ contract="IServicePortType"

   />

   </

service >

</

services >

<behaviors>

<serviceBehaviors>

<behavior name="ServiceBehavior" >

<serviceMetadata httpGetEnabled="true" externalMetadataLocation="..\service.wsdl"/>

</

behavior >

</

serviceBehaviors >

</

behaviors >

Ok, job is done. Next time , if you attempt to link  http://XXXX/Service.svc?wsdl, you wil get a flat wsdl.

 

2, Develop a custom behavior to support Inlined XSD.

转载于:https://www.cnblogs.com/fangyeyu/archive/2011/03/31/2001011.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值