C#调用Java写的webservice问题

ruoyan_o 2012-11-22 01:03:29
对方提供过来一个webservice地址(内网的):http://IP:9090/oss-webservice/services/iqsms?wsdl
C#调用
添加服务引用的时候配置文件中生成两个绑定协议,binding的就不贴上来了...
<endpoint address="http://IP:9090/oss-webservice/services/iqsms.iqsmsHttpSoap11Endpoint/"
binding="basicHttpBinding" bindingConfiguration="iqsmsSoap11Binding"
contract="ServiceIqsms.iqsmsPortType" name="iqsmsHttpSoap11Endpoint" />
<endpoint address="http://IP:9090/oss-webservice/services/iqsms.iqsmsHttpSoap12Endpoint/"
binding="customBinding" bindingConfiguration="iqsmsSoap12Binding"
contract="ServiceIqsms.iqsmsPortType" name="iqsmsHttpSoap12Endpoint" />

调用代码:
ServiceReference1.iqsmsPortTypeClient client = new ServiceReference1.iqsmsPortTypeClient();
client.queryShortMessage("xxx", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "xxx");

报错:
捕捉到 System.InvalidOperationException
Message=无法加载协定为“ServiceReference1.iqsmsPortType”的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选的终结点配置部分。
Source=System.ServiceModel
StackTrace:
在 System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext, String configurationName, ContractDescription contract, EndpointAddress address, Boolean wildcard, Boolean useChannelElementKind, ServiceEndpoint& serviceEndpoint)
在 System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
在 System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
在 System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
在 System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
在 System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
在 System.ServiceModel.ClientBase`1..ctor()
在 ConsoleApplication1.ServiceReference1.iqsmsPortTypeClient..ctor() 位置 D:\software\ConsoleApplication1\ConsoleApplication1\Service References\ServiceReference1\Reference.cs:行号 79
在 ConsoleApplication1.Program.Main(String[] args) 位置 D:\software\ConsoleApplication1\ConsoleApplication1\Program.cs:行号 14
InnerException:

删掉一个调用然后把maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"的值放大也不行,报错:服务器未提供有意义的回复;这可能是由协定不匹配、会话过早关闭或内部服务器错误引起的。


这样的情形谁遇到过?是不是对待接口协议什么问题之类的?不是很懂,求大神解答。

...全文
565 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruoyan_o 2012-12-03
  • 打赏
  • 举报
回复
没人给建议了吗
ruoyan_o 2012-11-27
  • 打赏
  • 举报
回复
都试过了。我把对方WSDL贴上来,对端是axis2 写的接口:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://impl.service.iqsms.webservice.sqm.oss.ffcs.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://impl.service.iqsms.webservice.sqm.oss.ffcs.com">
  <wsdl:documentation>iqsms</wsdl:documentation> 
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://impl.service.iqsms.webservice.sqm.oss.ffcs.com">
<xs:element name="queryShortMessage">
<xs:complexType>
<xs:sequence>
  <xs:element minOccurs="0" name="productId" nillable="true" type="xs:string" /> 
  <xs:element minOccurs="0" name="cutoffDate" nillable="true" type="xs:string" /> 
  <xs:element minOccurs="0" name="sourceType" nillable="true" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
<xs:element name="queryShortMessageResponse">
<xs:complexType>
<xs:sequence>
  <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>
  </wsdl:types>
<wsdl:message name="queryShortMessageRequest">
  <wsdl:part name="parameters" element="ns:queryShortMessage" /> 
  </wsdl:message>
<wsdl:message name="queryShortMessageResponse">
  <wsdl:part name="parameters" element="ns:queryShortMessageResponse" /> 
  </wsdl:message>
<wsdl:portType name="iqsmsPortType">
<wsdl:operation name="queryShortMessage">
  <wsdl:input message="ns:queryShortMessageRequest" wsaw:Action="urn:queryShortMessage" /> 
  <wsdl:output message="ns:queryShortMessageResponse" wsaw:Action="urn:queryShortMessageResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
<wsdl:binding name="iqsmsSoap11Binding" type="ns:iqsmsPortType">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
<wsdl:operation name="queryShortMessage">
  <soap:operation soapAction="urn:queryShortMessage" style="document" /> 
<wsdl:input>
  <soap:body use="literal" /> 
  </wsdl:input>
<wsdl:output>
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
<wsdl:binding name="iqsmsSoap12Binding" type="ns:iqsmsPortType">
  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
<wsdl:operation name="queryShortMessage">
  <soap12:operation soapAction="urn:queryShortMessage" style="document" /> 
<wsdl:input>
  <soap12:body use="literal" /> 
  </wsdl:input>
<wsdl:output>
  <soap12:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
<wsdl:binding name="iqsmsHttpBinding" type="ns:iqsmsPortType">
  <http:binding verb="POST" /> 
<wsdl:operation name="queryShortMessage">
  <http:operation location="queryShortMessage" /> 
<wsdl:input>
  <mime:content type="text/xml" part="parameters" /> 
  </wsdl:input>
<wsdl:output>
  <mime:content type="text/xml" part="parameters" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
<wsdl:service name="iqsms">
<wsdl:port name="iqsmsHttpSoap11Endpoint" binding="ns:iqsmsSoap11Binding">
  <soap:address location="http://132.228.213.45:9090/oss-webservice/services/iqsms.iqsmsHttpSoap11Endpoint/" /> 
  </wsdl:port>
<wsdl:port name="iqsmsHttpSoap12Endpoint" binding="ns:iqsmsSoap12Binding">
  <soap12:address location="http://132.228.213.45:9090/oss-webservice/services/iqsms.iqsmsHttpSoap12Endpoint/" /> 
  </wsdl:port>
<wsdl:port name="iqsmsHttpEndpoint" binding="ns:iqsmsHttpBinding">
  <http:address location="http://132.228.213.45:9090/oss-webservice/services/iqsms.iqsmsHttpEndpoint/" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>
宝_爸 2012-11-27
  • 打赏
  • 举报
回复
有InnerException吗? iqsmsHttpSoap11Endpoint和iqsmsHttpSoap12Endpoint都试过了? "这可能是由协定不匹配、会话过早关闭或内部服务器错误引起的。" 这个可就不好猜了 让对方提供正确的调用抓的包,你抓你的包,比较下看看有什么不同。 可以用Fiddler2抓包
ruoyan_o 2012-11-27
  • 打赏
  • 举报
回复
捕捉到 System.ServiceModel.CommunicationException Message=服务器未提供有意义的回复;这可能是由协定不匹配、会话过早关闭或内部服务器错误引起的。 Source=mscorlib StackTrace: Server stack trace: 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 WpfTest.ServiceIqsms.iqsmsPortType.queryShortMessage(queryShortMessageRequest request) 在 WpfTest.ServiceIqsms.iqsmsPortTypeClient.WpfTest.ServiceIqsms.iqsmsPortType.queryShortMessage(queryShortMessageRequest request) 位置 D:\_sky\Transfar.WCF\WpfTest\Service References\ServiceIqsms\Reference.cs:行号 100 在 WpfTest.ServiceIqsms.iqsmsPortTypeClient.queryShortMessage(String productId, String cutoffDate, String sourceType) 位置 D:\_sky\Transfar.WCF\WpfTest\Service References\ServiceIqsms\Reference.cs:行号 108 在 WpfTest.MainWindow.button1_Click(Object sender, RoutedEventArgs e) 位置 D:\_sky\Transfar.WCF\WpfTest\MainWindow.xaml.cs:行号 47 InnerException:
ruoyan_o 2012-11-27
  • 打赏
  • 举报
回复
也不行,异常:
ruoyan_o 2012-11-27
  • 打赏
  • 举报
回复
我试试五楼的方法
宝_爸 2012-11-27
  • 打赏
  • 举报
回复
” Message=无法加载协定为“ServiceReference1.iqsmsPortType”的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选的终结点配置部分。“ 这个错误是因为你为ServiceIqsms.iqsmsPortType定义了两个Endpoint,你得选一个,通过Endpoint的名字即可 ServiceReference1.iqsmsPortTypeClient client = new ServiceReference1.iqsmsPortTypeClient("iqsmsHttpSoap11Endpoint"); 或者 ServiceReference1.iqsmsPortTypeClient client = new ServiceReference1.iqsmsPortTypeClient("iqsmsHttpSoap12Endpoint"); 来选择使用不同的Endpoint.
jshi123 2012-11-27
  • 打赏
  • 举报
回复
wsdl贴出来看看
ruoyan_o 2012-11-26
  • 打赏
  • 举报
回复
试过 ...不行。难道只能写个Java中转类?
XBodhi. 2012-11-22
  • 打赏
  • 举报
回复
从新引用下, 貌似你的 messageName 对应不上。 客户端代理 和 wsdl
熙风 2012-11-22
  • 打赏
  • 举报
回复
我们做的项目也是调用java 的webservcies,但是配置文件生成的文件格式跟你不一样
   <setting name="XXX_Client_SystemWebService_SystemWebServiceImplService"
        serializeAs="String">
        <value>http://192.168.1.123:8080/XXX/webService/system/SystemWebService</value>
      </setting>


        private static SystemWebService.SystemWebServiceImplService _systemWebService = null;
        /// <summary>
        /// 获取SystemWebService对象
        /// </summary>
        /// <returns></returns>
        public static SystemWebService.SystemWebServiceImplService GetSystemWebService()
        {
            try
            {  
            if (_systemWebService == null)
            {
                _systemWebService = new SystemWebServiceImplService();
                _systemWebService.Timeout = WebServiceTimeOut;
                _systemWebService.Url =http://192.168.1.123:8080/XXX/webService/system/SystemWebService?wsdl";
            }
            return _systemWebService;
            }
            catch (Exception ex)
            {
                throw;
            }
        }

110,546

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧