gpt4 book ai didi

wcf - SOAP、JSON 和 POX 在同一个安静的 wcf 中

转载 作者:行者123 更新时间:2023-12-04 05:58:29 30 4
gpt4 key购买 nike

我试图在同一个 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>

当我拥有所有端点时,它会给出以下错误:
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)

如果我注释掉 json 端点,一切正常。

你能帮我找出原因吗??

提前致谢。

最佳答案

好吧,我刚刚添加了更改 json 行为的绑定(bind)配置。我对 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>

并添加了绑定(bind)配置:
 <webHttpBinding>
<binding name="WebHttp" >
<security mode="None"></security>
</binding>

<binding name="WebjsonHttp" >
<security mode="None"></security>
</binding>
</webHttpBinding>

关于wcf - SOAP、JSON 和 POX 在同一个安静的 wcf 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4605419/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com