对方提供过来一个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"的值放大也不行,报错:服务器未提供有意义的回复;这可能是由协定不匹配、会话过早关闭或内部服务器错误引起的。
这样的情形谁遇到过?是不是对待接口协议什么问题之类的?不是很懂,求大神解答。
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"的值放大也不行,报错:服务器未提供有意义的回复;这可能是由协定不匹配、会话过早关闭或内部服务器错误引起的。
这样的情形谁遇到过?是不是对待接口协议什么问题之类的?不是很懂,求大神解答。
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;
}
}
或者
ServiceReference1.iqsmsPortTypeClient client = new ServiceReference1.iqsmsPortTypeClient("iqsmsHttpSoap12Endpoint");来选择使用不同的Endpoint.
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:
这个可就不好猜了让对方提供正确的调用抓的包,你抓你的包,比较下看看有什么不同。
可以用Fiddler2抓包
写的接口: <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>