WebService 错误解决记录

1.集成Windows认证

MI_ILO062_PORDCR1_PORDCR103Client client = new MI_ILO062_PORDCR1_PORDCR103Client();

client.ClientCredentials.UserName.UserName = "PI000007";
client.ClientCredentials.UserName.Password = "123qwe";

client.MI_ILO062_PORDCR1_PORDCR103(PORDCR103);

配置文件:

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
              <binding name="MI_ILO062_PORDCR1_PORDCR103Binding">
                  <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Windows" proxyCredentialType="Windows" realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
              </binding>
            </basicHttpBinding>
            <customBinding>
                <binding name="SapServiceSoap12">
                    <textMessageEncoding messageVersion="Soap12" />
                    <httpTransport />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://antad20pd1.anta.com:8000/XISOAPAdapter/MessageServlet?channel=:BS_EPOS:CC_SOAP_ILO062_SENDER&amp;version=3.0&amp;Sender.Service=BS_EPOS&amp;Interface=http%3A%2F%2Fpi.anta.com%2Fepos%2Fgeneral%5EMI_ILO062_PORDCR1_PORDCR103"
                binding="basicHttpBinding" bindingConfiguration="MI_ILO062_PORDCR1_PORDCR103Binding" 
                contract="ServiceReference2.MI_ILO062_PORDCR1_PORDCR103" name="MI_ILO062_PORDCR1_PORDCR103Port"
                      behaviorConfiguration="ImpersonationBehavior"/>
        </client>

      <behaviors>
        <endpointBehaviors>
          <behavior name="ImpersonationBehavior">
            <clientCredentials>
              <windows allowedImpersonationLevel="Impersonation"/>
            </clientCredentials>
          </behavior>
        </endpointBehaviors>
      </behaviors>
    </system.serviceModel>

2.The one-way operation returned a non-null message with Action=''.

由WSDL生成的代理类,默认IsOneWay=ture,需改为false,否则调用会报错。

3.HTTP 415 Unsupported Media Type.

When you check "Do Not use SOAP Envelop", the SOAP adapter chooses application/xml instead of text/xml.

You can change the content type with help of the MessageTransformBean. You put the bean in the module chain of the receiver channel and add the parameter Transform.ContentType = text/xml

原文地址:https://www.cnblogs.com/KevinG/p/4092529.html