Metadata extension problems

Dec 21, 2010 at 7:22 AM
Edited Dec 21, 2010 at 7:23 AM

I absolutely love this tool. It has saved me a lot of time. However, I am having a difficult time getting the StaticMetadataBehavior properly configured. I have taken the output.config and merged it with the web.config. However, I'm unable to browse for the metadata file at the specified endpoint http://localhost:43293/Service/wsdl. I added the source to the project and traced the failure to the MetadataServiceExtension.cs -> line 80

 

MetadataServiceRuntimeProperties metadataServiceRuntimeProperties = new MetadataServiceRuntimeProperties(this.metadataServiceUri, this.rootMetadataFileLocation);
metadataServiceHost.Extensions.Add(metadataServiceRuntimeProperties);
this.metadataServiceHost.Open();

 

The method fails on the open call and I get a CommunicationException saying that "HTTP could not register URL http://+:43293/Services/wsdl/ because TCP port 43293 is being used by another application"

Please help.

Web.config follows

 

<system.serviceModel>
	<behaviors>
		<serviceBehaviors>
			<behavior name="metadataServiceExtension">
				<metadataService metadataUrl="wsdl" rootMetadataFileLocation="C:\SRC\Contracts\MyService.wsdl" />
			</behavior>
		</serviceBehaviors>
	</behaviors>
	<bindings>
		<basicHttpBinding>
			<binding name="BasicHttpBinding_MyServiceInterface" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
				<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
				<security mode="None">
					<transport clientCredentialType="None" proxyCredentialType="None"
                        realm="">
						<extendedProtectionPolicy policyEnforcement="Never" />
					</transport>
					<message clientCredentialType="UserName" algorithmSuite="Default" />
				</security>
			</binding>
		</basicHttpBinding>
	</bindings>
	<extensions>
		<behaviorExtensions>
			<add name="metadataService" type="Thinktecture.ServiceModel.Extensions.Metadata.StaticMetadataBehaviorElement, Thinktecture.ServiceModel.Extensions.Metadata, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />
		</behaviorExtensions>
	</extensions>
	<services>
		<service behaviorConfiguration="metadataServiceExtension" name="Services.MyService">
			<endpoint address="http://localhost:47542/PreviewService" behaviorConfiguration=""
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyServiceInterface"
                contract="IMyService" />
		</service>
	</services>
</system.serviceModel>

 

Developer
Jan 4, 2011 at 11:27 AM

Hi Gavin,

I would use the externalMetadataLocation attribute on the <serviceMetadata> element instead.

http://msdn.microsoft.com/en-us/library/ms731317.aspx

You call also try using TcpView from SysInternals to find out what has the port open.

http://live.sysinternals.com/Tcpview.exe

Cheers,

Alex.