有高手吗?WCF

qq598235031 2012-04-24 02:22:34
在部署WCF服务时,遇到一个问题
测试客户端调用服务 返回一个错误,远程服务器返回了意外响应:<407>proxy authentication required
1.测试客户端与WCF在同一台机器上,服务正常
2.测试客户端与WCF服务在同一网段内 ,服务正常
3.测试客户端与WCF服务在不同网段内,返回一个错误,远程服务器返回了意外响应:<407>proxy authentication required
4.在IE里设置代理后,在IE输入网址(http://10.128.167.112:8080/ScanBusinessService/?wsdl),可以访问服务
所以,在不同网段,如何解决代理的问题呢?

在.net环境下开发个wcf服务,宿主在winform程序里面。遇到提示《407》proxy authentication
required

网络环境,WCF服务部署在局域网内,采用小型机win 2003操作系统。
我写了个测试客户端测试服务.代码大致如下
public partial class Program
{
static ServiceReference1.ServiceClient instance = null;
instance = new WebServiceTest.ServiceReference1.ServiceClient(binding, point);
//调用服务接口
instance.getInfo("");

配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy=" ">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/ScanBusinessService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="ServiceReference1.IService" name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>
</configuration>

服务
[ServiceContract]
public interface IService
{
[OperationContract]
string getInfo(string xmlData);

public class Service : IService
{
public string getInfo(string xmlData)
{
。。。。。
}
}

配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- 部署服务库项目时,必须将配置文件的内容添加到
主机的 app.config 文件中。System.Configuration 不支持库的配置文件。-->
<system.serviceModel>
<services>
<service name="ScanBusinessService.Service" behaviorConfiguration="ScanBusinessService.ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8080/ScanBusinessService/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- 除非完全限定,否则地址将与上面提供的基址相关 -->
<endpoint address ="" binding="basicHttpBinding" contract="ScanBusinessService.IService">
<!--
部署时,应删除或替换下列标识元素,以反映
在其下运行部署服务的标识。删除之后,WCF 将
自动推导相应标识。
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- 元数据交换终结点由服务用于向客户端做自我描述。-->
<!-- 此终结点不使用安全绑定,应在部署前确保其安全或将其删除-->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ScanBusinessService.ServiceBehavior">
<!-- 为避免泄漏元数据信息,
请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadata httpGetEnabled="True"/>
<!-- 要接收故障异常详细信息以进行调试,
请将下值设置为 true。在部署前
设置为 false 以避免泄漏异常信息-->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

...全文
160 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

111,126

社区成员

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

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

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