gen*_*ser 8 rest wcf json soap
我想在同一个WCF服务中使用SOAP和RESTful.除了一个问题之外,我已经将它除了.以下是我的web.config:
<service behaviorConfiguration="webBehaviour" name="MyServices">
<clear />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttp"
name="basicHttpBinding" contract="DJSharedServices.IMyServices" />
<endpoint address="ws" binding="wsHttpBinding" bindingConfiguration="WsHttp"
name="wsHttpBinding" contract="DJSharedServices.IMyServices" />
<endpoint address="web" binding="webHttpBinding" bindingConfiguration="WebHttp" behaviorConfiguration="webBehavior"
name="webHttpBinding" contract="DJSharedServices.IMyServices" />
<endpoint address="json" binding="webHttpBinding" bindingConfiguration="WebHttp" behaviorConfiguration="webJSONBehavior"
name="webJSONHttpBinding" contract="DJSharedServices.ISharedServices" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" name="mexBinding" />
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
当我有所有端点时,它会给出以下错误:
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.ServiceModel.Description.WsdlExporter.CreateWsdlBindingAndPort(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName, Port& wsdlPort, Boolean& newBinding, Boolean& bindingNameWasUniquified)
at System.ServiceModel.Description.WsdlExporter.ExportEndpoint(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName)
at System.ServiceModel.Description.WsdlExporter.ExportEndpoints(IEnumerable`1 endpoints, XmlQualifiedName wsdlServiceQName)
at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequest(Message httpGetRequest, String[] queries, Message& replyMessage)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.Get(Message message)
at SyncInvokeGet(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Run Code Online (Sandbox Code Playgroud)
如果我评论json终点,事情就好了.
你能帮我找出原因吗?
提前致谢.
gen*_*ser 12
好吧,我刚刚添加了更改json行为的绑定配置.我正在为JSON和POX使用相同的binging配置.现在我已将配置更改为:
<service behaviorConfiguration="WebBehaviour" name="MyServices">
<clear />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttp"
name="basicHttpBinding" contract="DJSharedServices.IMyServices" />
<endpoint address="ws" binding="wsHttpBinding" bindingConfiguration="WsHttp"
name="wsHttpBinding" contract="DJSharedServices.IMyServices" />
<endpoint address="web" binding="webHttpBinding" bindingConfiguration="WebHttp" behaviorConfiguration="webBehavior"
name="webHttpBinding" contract="DJSharedServices.IMyServices" />
<endpoint address="json" binding="webHttpBinding" bindingConfiguration="WebjsonHttp" behaviorConfiguration="webJSONBehavior"
name="webJSONHttpBinding" contract="DJSharedServices.IMyServices" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" name="mexBinding" />
</service>
Run Code Online (Sandbox Code Playgroud)
并添加了绑定配置:
<webHttpBinding>
<binding name="WebHttp" >
<security mode="None"></security>
</binding>
<binding name="WebjsonHttp" >
<security mode="None"></security>
</binding>
</webHttpBinding>
Run Code Online (Sandbox Code Playgroud)