Reputation: 15807
We have a WCF webservice selfhosted in a windows service application.
It works fine to generate and call a simple method from both a .NET winform application and SoapUI(after changin to correct IP and set authentication header).
The problem is that when trying to add the WSDL to a BizTalk we get "Error consuming WCF service metadata. Object reference not set to an instance of an object". and nothing more.
I have search internet and there is some that have hade the same problem and they are talking about namespace problems. I have checked the generated .NET winform proxy but there is no warnings or anything that might suggest problems with namespaces? I notice in the WSDL that some namespaces tags do only have a "" value but not sure if that might be a problem.
Is there any way to get more information from Biztalk about where the error might be in this massive WSDL?
When browsing the WSDL from another computer it will use localhost(instead of the IP och DNS) so I have to use WSDL singelfile to genereate the proxy and I have to manually change the URL to the specific IP in the client to get it working. This should however not be the problem.
Here is how the service is started :
_serviceHost = new ServiceHost(typeof(T), new Uri(baseEndpoint.Address));
ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior
{
MaxConcurrentCalls = 200,
MaxConcurrentInstances = 2147483647,
MaxConcurrentSessions = 2000,
};
_serviceHost.Description.Behaviors.Add(throttleBehavior);
_serviceHost.Description.Behaviors.Add(smb.HttpGetEnabled = true);
foreach (var endpointDescription in _additionalServiceEndpoints)
{
var endpoint = new ServiceEndpoint(ContractDescription, endpointDescription.Binding, new EndpointAddress(endpointDescription.Address));
_endpointBehaviors.ForEach(c => endpoint.EndpointBehaviors.Add(c));
_serviceHost.AddServiceEndpoint(endpoint);
}
_serviceBehaviors.ForEach(c => _serviceHost.Description.Behaviors.Add(c));
ServiceAuthorizationBehavior serviceAuthorizationBehavior = _serviceHost.Description.Behaviors.Find<ServiceAuthorizationBehavior>();
if (serviceAuthorizationBehavior == null)
{
_serviceHost.Description.Behaviors.Add(new ServiceAuthorizationBehavior());
}
if (_authorizationPolicies.Count > 0)
{
serviceAuthorizationBehavior.ExternalAuthorizationPolicies = new ReadOnlyCollection<IAuthorizationPolicy>(_authorizationPolicies.ToArray());
serviceAuthorizationBehavior.PrincipalPermissionMode = PrincipalPermissionMode.Custom;
serviceAuthorizationBehavior.ServiceAuthorizationManager = new CustomServiceAuthorizationManager();
}
((ServiceBehaviorAttribute)_serviceHost.Description.Behaviors[typeof(ServiceBehaviorAttribute)]).MaxItemsInObjectGraph = 2147483647;
((ServiceBehaviorAttribute)_serviceHost.Description.Behaviors[typeof(ServiceBehaviorAttribute)]).IncludeExceptionDetailInFaults = true;
_serviceHost.Open();
Upvotes: 1
Views: 1025
Reputation: 8731
I just had the same error when trying to consume .svc?singleWsdl. When I consume as just .svc into the "Add Generated Items" wizard then it works.
Upvotes: 0
Reputation: 3266
Have you tried the solution which is described in this forum thread: https://social.msdn.microsoft.com/Forums/en-US/19105b96-5ec4-40f1-972b-2e04f889061f/biztalk-2010-error-consuming-wcf-service-metadata-object-reference-not-set-to-an-instance-of-an?forum=biztalkgeneral
It points to a blog post located here: https://blogs.msdn.microsoft.com/kerreybpi/2009/02/05/biztalk-error-wcf-service-consuming-wizard/
The solution might be (from the link above):
1, Generate WSDL and XSD files by using svcutil tool
svcutil.exe /t:metadata http://yourservice
2, Verify nodes in WSDL file, make sure the node has a target namespace define. It doesn't matter what attribute value you use, maybe just looks like http://any.
3, Select Metadata Files(WSDL and XSD) as the source
4, Everything should be fine.
Upvotes: 1