调用Weblogic Web服务中的C#winform(访问被拒绝操作方法)

时间:2013-11-20 08:02:47

标签: c# service web weblogic

求助:(我的英语非常糟糕。我无法做出进一步的解释。我无法做出进一步的解释。我无法做出进一步的解释。

的App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.net>
    <defaultProxy useDefaultCredentials="true" />
  </system.net>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding 
                 name="XXTG_HR_ROUTING_WS_PUBPortBinding" 
                 closeTimeout="00:01:00"
                 openTimeout="00:01:00" 
                 receiveTimeout="00:10:00" 
                 sendTimeout="00:01:00"
                 allowCookies="false" 
                 bypassProxyOnLocal="false" 
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferPoolSize="524288" 
                 maxBufferSize="65536" 
                 maxReceivedMessageSize="65536"
                 textEncoding="utf-8" 
                 transferMode="Buffered" 
                 messageEncoding="Text"
                 >        
          <readerQuotas 
                maxDepth="32" 
                maxStringContentLength="8192" 
                maxArrayLength="16384"
                maxBytesPerRead="4096" 
                maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport 
                clientCredentialType="Basic" 
                proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="XXTG_HR_ROUTING_WS_PUBPortBinding1" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://10.0.0.5:33021/xxtg_hr_routing_ws_pub/XXTG_HR_ROUTING_WS_PUB"
        binding="basicHttpBinding" bindingConfiguration="XXTG_HR_ROUTING_WS_PUBPortBinding1"
        contract="WS.XXTG_HR_ROUTING_WS_PUB" name="XXTG_HR_ROUTING_WS_PUBPort1" />
    </client>
  </system.serviceModel>
</configuration>

Form1.cs的

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WS_Data.WS;

namespace WS_Data
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            WS.XXTG_HR_ROUTING_WS_PUBClient snn = new WS.XXTG_HR_ROUTING_WS_PUBClient();

            var clientCredentials = snn.ClientCredentials;

            clientCredentials.UserName.UserName = "snnuser";
            clientCredentials.UserName.Password = "snnpass";


            string getsnn = snn.leave_resp_list("percode").ToString();
            textBox1.Text = getsnn;
        }
    }
}

错误:拒绝访问操作leave_resp_list 我使用代理

1 个答案:

答案 0 :(得分:0)

在WCF绑定配置

下尝试此操作
  <security mode="TransportCredentialOnly">
    <transport 
            clientCredentialType="Basic" 
            proxyCredentialType="None"
            realm="" />
  </security>