Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic WEb Reference URL at Runtime with a Desktop Application

Posted on 2009-07-10
12
Medium Priority
?
495 Views
Last Modified: 2013-12-17
Im accessing a Web Reference in my desktop application.  I want to edit the Web Reference URL under certain circumstances , but i don't know how... i have investigated in internet but only I found examples with Web Appications ,  there are mentions that the key is the file Web.Config, but in desktop i dont have that file... how i can do this?
0
Comment
Question by:Veljean
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 8

Expert Comment

by:RyanAndres
ID: 24827802
Note sure if you can do that during runtime. The endpoint should be in the app.config or your AssemblyName.config (when compiled).

Changing the web reference url is directly associated with its Service References files location in the Service References directory (ie. wsdl, disco, datasources, and the other xsd files).

What are you really trying to do?
0
 
LVL 1

Author Comment

by:Veljean
ID: 24827831
Hi Ryan

I need to switch during Runtime the Web Reference URLs

http://maptp12.map24.com/map24/webservices1.5
http://maptp17.map24.com/map24/webservices1.5
http://maptp27.map24.com/map24/webservices1.5

these are the 3 possible values.

Only changing the URL value from the app.config xml file  can fix my problem?
0
 
LVL 3

Expert Comment

by:MrHswede
ID: 24827841
Not 100% sure if this is what you are looking for.
Here is two links to a microsoft web-page
http://msdn.microsoft.com/en-us/library/aa984386(VS.71).aspx
http://msdn.microsoft.com/en-us/library/d9w023sx.aspx 
 
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:RyanAndres
ID: 24827940
Veljean,

I would add all web service endpoints as references and put logic in your that would select which one to use. Keep in mind each reference will not have the same base type so you may have to use a proxy to seamlessly control all of them.
0
 
LVL 1

Author Comment

by:Veljean
ID: 24828047
mmmm sounds good... i dont have many experience in this but I like the idea, I think all the references are the same basically I switched URL because each one si a different continent (Asia, America, etc) and im developing a geocoder. Where i can get information in order to do  this? Thank you for you help!!
0
 
LVL 15

Expert Comment

by:jinal
ID: 24828720
For example your webservice proxy class name TestWebSerivce.Service1

Try this way.

TestWebService.Service1.Url =  ""  ;  // your url;

If you not found Url property over here then please add System.Web.Services assembly refrence.
0
 
LVL 1

Author Comment

by:Veljean
ID: 24859751
Hi jinal:

Hi try your solution but without result... i dont know if im getting the correct assembly or class name... can you help me to get it?  
0
 
LVL 1

Author Comment

by:Veljean
ID: 24859838
RyanAndres... I try your solution too, but is not practical since I use a lot of different objects and code made by the Web Service,  put logic and select the appropriated Reference makes my code long and not practical... could be my last option but if i have a better one I would like to do it... any other ideas ?  :(
0
 
LVL 15

Expert Comment

by:jinal
ID: 24859940
Can you put your code snippet ove here ?

I already used this at many place so i can help you .
0
 
LVL 1

Author Comment

by:Veljean
ID: 24860053
This is one part (I think the most representative), as you can se I use a lot of objects from the WEb Reference " Map24Geocoder51" , i can edit the url of  objMap24Geocoder5 like

objMap24Geocoder5.Url = "http://maptp17.map24.com/map24/webservices1.5?soap=Map24Geocoder51&service_version=20070724";

But the rest of the objects (RH
,objSEarchFreeRequest , etc) don't have this property (url) , so they are referenced to the first web reference with the default url.

Let me know if you have more questions...

Map24Geocoder51.Map24Geocoder51 objMap24Geocoder5 = new Map24Geocoder51.Map24Geocoder51();
 
Map24Geocoder51.RequestHeader RH = new Map24Geocoder51.RequestHeader();
RH.Map24ID ="codeID";
 
Map24Geocoder51.MapSearchFreeRequest objSEarchFreeRequest = new Map24Geocoder51.MapSearchFreeRequest();
 
Map24Geocoder51.MProperty objMProperty = new Map24Geocoder51.MProperty();
objMProperty.Key = "Type";
objMProperty.Value = "7";
 
 
Map24Geocoder51.MProperty[] objMPropertyArray = new Map24Geocoder51.MProperty[]
            {
                objMProperty
            };
                       
string[] arrAdress =  new string[dtTableG.Rows.Count];
            
objSEarchFreeRequest.MaxNoOfAlternatives = 1;
objSEarchFreeRequest.Properties = objMPropertyArray;
 
Map24Geocoder51.MapSearchResponse Response = objMap24Geocoder5.searchFree(RH, objSEarchFreeRequest);
 
for (int r = 0; r < dtTableG.Rows.Count; r++)
{
 
  if (dtTableG.Rows[r].ItemArray[0].ToString() != " ")
   {
                    arrAdress[r] = dtTableG.Rows[r].ItemArray[0].ToString() + " " + dtTableG.Rows[r].ItemArray[1].ToString() + " " + dtTableG.Rows[r].ItemArray[2].ToString() + " " + dtTableG.Rows[r].ItemArray[3].ToString() + " " + dtTableG.Rows[r].ItemArray[4].ToString() + " " + dtTableG.Rows[r].ItemArray[5].ToString();
 
objSEarchFreeRequest.SearchText= arrAdress[r];
                                
MakeParenTable(Response,table);
                   
                }
 
            }
            
            clsSaveData.ExportExcel(table, "c:\\ResultGeo.xml");
        }

Open in new window

0
 
LVL 15

Accepted Solution

by:
jinal earned 2000 total points
ID: 24860131
You jsut have to set for this objMap24Geocoder5 .

But each time when you create object you have to set that it works.

Map24Geocoder51.Map24Geocoder51 objMap24Geocoder5 = new Map24Geocoder51.Map24Geocoder51();
objMap24Geocoder5.Url = "set your dynamic url over here"; 
Map24Geocoder51.RequestHeader RH = new Map24Geocoder51.RequestHeader();
RH.Map24ID ="codeID";
 
Map24Geocoder51.MapSearchFreeRequest objSEarchFreeRequest = new Map24Geocoder51.MapSearchFreeRequest();
 
Map24Geocoder51.MProperty objMProperty = new Map24Geocoder51.MProperty();
objMProperty.Key = "Type";
objMProperty.Value = "7";
 
 
Map24Geocoder51.MProperty[] objMPropertyArray = new Map24Geocoder51.MProperty[]
            {
                objMProperty
            };
                       
string[] arrAdress =  new string[dtTableG.Rows.Count];
            
objSEarchFreeRequest.MaxNoOfAlternatives = 1;
objSEarchFreeRequest.Properties = objMPropertyArray;
 
Map24Geocoder51.MapSearchResponse Response = objMap24Geocoder5.searchFree(RH, objSEarchFreeRequest);
 
for (int r = 0; r < dtTableG.Rows.Count; r++)
{
 
  if (dtTableG.Rows[r].ItemArray[0].ToString() != " ")
   {
                    arrAdress[r] = dtTableG.Rows[r].ItemArray[0].ToString() + " " + dtTableG.Rows[r].ItemArray[1].ToString() + " " + dtTableG.Rows[r].ItemArray[2].ToString() + " " + dtTableG.Rows[r].ItemArray[3].ToString() + " " + dtTableG.Rows[r].ItemArray[4].ToString() + " " + dtTableG.Rows[r].ItemArray[5].ToString();
 
objSEarchFreeRequest.SearchText= arrAdress[r];
                                
MakeParenTable(Response,table);
                   
                }
 
            }
            
            clsSaveData.ExportExcel(table, "c:\\ResultGeo.xml");
        }

Open in new window

0
 
LVL 1

Author Comment

by:Veljean
ID: 24860567
Thank you jinal!!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question