我有一个SOAP WCF服务地址,我想从控制台应用程序访问它。
我已经从服务参考中将此服务添加到了我的控制台项目,这是以下生成配置文件
<system.serviceModel>
<bindings>
<customBinding>
<binding name="ZINTWS0018binding">
<mtomMessageEncoding messageVersion="Soap11WSAddressing10" />
<httpsTransport authenticationScheme="Basic" />
</binding>
<binding name="ZINTWS0018binding_SOAP12">
<mtomMessageEncoding />
<httpsTransport authenticationScheme="Basic" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://34sapqa6.arkas.com:8000/sap/bc/srt/rfc/sap/zintws0018/120/zintws0018service/zintws0018binding"
binding="customBinding" bindingConfiguration="ZINTWS0018binding"
contract="SAPServiceRef.ZINTWS0018" name="ZINTWS0018binding" />
<endpoint address="http://34sapqa6.arkas.com:8000/sap/bc/srt/rfc/sap/zintws0018/120/zintws0018service/zintws0018binding"
binding="customBinding" bindingConfiguration="ZINTWS0018binding_SOAP12"
contract="SAPServiceRef.ZINTWS0018" name="ZINTWS0018binding_SOAP12" />
</client>
</system.serviceModel>
我也分配了用户名和密码,例如;
client.ClientCredentials.UserName.UserName = "***";
client.ClientCredentials.UserName.Password = "***";
当我尝试访问此服务时,我会收到以下错误;
您有建议吗?我在这一点上犯错?谢谢。
{"The content type text/xml of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<?xml version="1.0" encoding="utf-8"?><wsdl:definitions targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions"><wsdl:documentation><sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/></wsdl:documentation><wsp:UsingPolicy wsdl:required="true"/><wsp:Policy wsu:Id="BN_BN_ZINTWS0018binding"><saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding'."
}
请检查是否可以访问浏览器中的地址。如果不是这样,那可能会指出一个问题...