从C#问题

时间:2015-11-18 16:19:19

标签: java c# web-services soap jax-ws

我必须在VPN网络中使用SOAP Web服务(因此无法测试它),用Java编写( JAX-WS webservice)。 我无法访问服务器端。当我尝试从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>

任何帮助?

1 个答案:

答案 0 :(得分:0)

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

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

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