繁体   English   中英

从C#问题访问JAX-WS Web服务

[英]Accessing JAX-WS webservice from C# issue

我必须在用Java编写的VPN网络中使用SOAP Web服务(因此您无法对其进行测试)( JAX-WS Web服务)。 我在服务器端没有访问权限。 当我尝试从C#4.0客户端调用Web方法时,出现此异常:

  The CustomBinding on the ServiceEndpoint with contract 'ServicesSoap' lacks a TransportBindingElement.  Every binding must have at least one binding element that derives from TransportBindingElement.
at System.ServiceModel.Channels.Binding.EnsureInvariants(String contractName)
   at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
   at System.ServiceModel.ChannelFactory.CreateFactory()
   at System.ServiceModel.ChannelFactory.OnOpening()
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ChannelFactory.EnsureOpened()
   at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
   at System.ServiceModel.ClientBase`1.CreateChannel()
   at System.ServiceModel.ClientBase`1.CreateChannelInternal()
   at System.ServiceModel.ClientBase`1.get_Channel()
   at GatewayClient.Lotto.ServicesSoapClient.GatewayClient.Lotto.ServicesSoap.InfoRequest(InfoRequestRequest request)
   at GatewayClient.Lotto.ServicesSoapClient.InfoRequest(infoDataIn request)
   at GatewayClient.MainWindow.InfoRequestButton_Click(Object sender, RoutedEventArgs e)

这是我的app.config:

   <system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="ServicesSoapPortBinding">
                <textMessageEncoding messageVersion="Soap12" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://xxx.yyy/Services"
            binding="customBinding" bindingConfiguration="ServicesSoapPortBinding"
            contract="ServiceReference1.ServicesSoap" name="ServicesSoapPort" />
    </client>
</system.serviceModel>

有什么帮助吗?

我已经解决了在app.config中的绑定标记中添加httpTransport的问题:

<binding name="ServicesSoapPortBinding">
    <textMessageEncoding messageVersion="Soap12" />
    <httpTransport/>
</binding>

我必须在Visual Studio“服务引用”功能中添加服务引用。 尝试使用svcutil ,我得到了另一个不同的异常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM