how to consume webservices from asp.net mvc application

柔情痞子 提交于 2020-01-17 01:39:05

问题


There is a external web services.

I can invoke it from my winform application, but I cannot invoke it from my asp.net mvc web application.

Error message is like this :

System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://ihexds.nist.gov:9080/tf6/services/xdsrepositoryb that could accept the message. This is often caused by an incorrect address or SOAP action.

Is there anything to configure for my mvc web application to consume it?

Edit :

following is my code to invoke web services

WCF.Message msgInput, msgOutput;
msgInput = WCF.Message.CreateMessage(MESSAGE_VERSION, PROVIDEANDREGISTERDOCUMENTSETB_WSAACTION, request);
msgOutput = WCF.Message.CreateMessage(WCF.MessageVersion.Soap12WSAddressing10, "");

string endpointName = GetRepositoryEndPointName();
XDSRepository.XDSRepositoryClient client = new XDSRepository.XDSRepositoryClient(endpointName);

msgOutput = client.ProvideAndRegisterDocumentSet(msgInput);

回答1:


Judging from your comments, I think your problem is proxy server related. I think you're using a proxy server internal to your company. You have to specify in you web.config file that you want the dotnet code to use the credentials you're logged on with. Add this to your web.config and try again:

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true" >
    </defaultProxy>
</system.net>

It's also possible that you're working with a .pac script. In that case you have to explicitly specify the proxy server like so:

<system.net>
    <defaultProxy useDefaultCredentials="true">
        <proxy proxyaddress="http://proxyserver:proxyport"/>
    </defaultProxy>
</system.net>


来源:https://stackoverflow.com/questions/6276979/how-to-consume-webservices-from-asp-net-mvc-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!