any help is appricited I have one Sample service and one Test console application I have accessing sample service metadata by adding reference from same soln to the console appln and i am getting binding info. also i am hosting(publishing) same service in IIS and adding reference through service URL in Test Console appln and I am Getting result.
Now problem is tat my running Data service hosted(published) in IIS i am adding the reference and trying to read the metadata from service URL its giving me Error. Metadata contains a reference that cannot be resolved: 'http://localhost:9092/TransactionDataService.svc/mex'.
I am using mexhttpbinding with multiplebingind = true in both(sample + my running data service) cases
web config for samp-le serviec
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="ServiceApp.Service1">
<endpoint address="" binding="wsHttpBinding" name="Service1Endpoint" contract="ServiceApp.IService1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Code for accesing metadata
EndpointAddress serviceEndpointAddress = new EndpointAddress("http://localhost:30617/Service1.svc/mex");
var endpointCollection = MetadataResolver.Resolve(typeof(IService1), serviceEndpointAddress);
foreach (var endpoint in endpointCollection)
{
Type bindingType = endpoint.Binding.GetType();
if (bindingType.Equals(typeof(WSHttpBinding)))
{
Console.WriteLine("Eureka!!!");
}
}
web config for Data service
<bindings>
<wsHttpBinding>
<binding name="WSHttp" openTimeout="01:00:00" closeTimeout="01:00:00" sendTimeout="01:00:00" receiveTimeout="01:00:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="0" maxReceivedMessageSize="2147483647">
<reliableSession enabled="true" />
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<!--Service Behaviors-->
<behaviors>
<serviceBehaviors>
<behavior name="DataAccessBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<!--Service Configuration-->
<services>
<service name="TransactionDataAccess" behaviorConfiguration="DataAccessBehavior">
<endpoint name="DataAccessServiceEndpoint" address="" binding="wsHttpBinding" bindingConfiguration="WSHttp" contract="TransactionDataServices.ITransactionDataService"/>
<endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
Code for accesing metadata for data service is same except serviec url
See if by any chance you forgot to decorate your transported classes with [DataContract] attributes (don't forget [DataMember] as well).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With