c# - class library application not using the app.config file -
i facing problem while consuming webservice , making web service call.
i creating class library application generate dll , dll used other application connect webservice.i have received wsdl file third part , "add service reference" , used proxy classes create soap body. have 2 issues need add wsse:security header soap message below
<wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:usernametoken> <wsse:username>username</wsse:username> <wsse:password>password</wsse:password> </wsse:usernametoken> </wsse:security>
to handle , connect webserivce endpoint address have modified app.config file (which got generated when add service reference) include header tag. below app.config file
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configsections> </configsections> <system.servicemodel> <bindings> <basichttpbinding> <binding name="icms-http-wsbinding"> <security mode="transport"> <transport clientcredentialtype="none" proxycredentialtype="none" realm="" /> <message clientcredentialtype="username" algorithmsuite="default" /> </security> </binding> </basichttpbinding> </bindings> <client> <endpoint address="https://devs-dp-in.wellpoint.com/claims/2.0/get_ihealthicms_results" binding="basichttpbinding" bindingconfiguration="icms-http-wsbinding" contract="ihlth_service1.icmshttpwsporttype" name="icms-http-wsporttype"> <headers> <wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:usernametoken> <wsse:username>username</wsse:username> <wsse:password>password</wsse:password> </wsse:usernametoken> </wsse:security> </headers> </endpoint > </client> </system.servicemodel> </configuration>
when tried initialize client below facing error not find endpoint element name 'icms-http-wsporttype' , contract 'ihlth_service.icmshttpwsporttype' in servicemodel client configuration section. might because no configuration file found application, or because no endpoint element matching name found in client element
service.cmshttpwsporttypeclient client = new service.cmshttpwsporttypeclient("icms-http-wsporttype");
i modified code create binding , endpoint address inside code , pass client worked fine again faced issue @ security header missing provided security information in app.config file
basichttpbinding binding = new basichttpbinding(basichttpsecuritymode.transport); endpointaddress address = new endpointaddress("https://devs-dp-in.wellpoint.com/claims/2.0/get_ihealthicms_results");
is there way can read app.config file or code refer config file information rather giving inside code.
this entire code working fine in windows application reading app.config file not in class library application there reason behind ?
any 1 please give idea
the app.config
of dll is, @ best, reminder of needs placed in app.config
of exe consumes dll or web.config
of website consumes dll.
it's not used default configuration system, , it's unfortunate tooling (such add service reference
) create 1 in class library project , give no warning this.
Comments
Post a Comment