• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 799
  • Last Modified:

How to use web.config, asmx and default.aspx

I am having a problem getting my DEFAULT.ASPX file to get the connection in the WEB.CONFIG file, which is calling on a webservice asmx located on a website server. Below are my settings in the web.config file and the default.aspx file.

Notes:
1. I hand coded these files, so there are no other files in play.
2. When I use Visual Studio 2005, there are lots of other files. However, when I copy the files to my website server, I encounter other issues. I cannot use the 'publish' feature in VS2005. I am just trying to run a test to see how the ASMX file works. In this case, the ASMX file is returning a dataset, which the default.aspx file will display to the user.

Questions:
1. What am I doing wrong?
2. Does the asmx file, or something else need to be compiled before I upload it to my server?
3. Where is the location of the web.config file? Can it be in the sub-folder where default.aspx is or does it need to be in the website root folder?

[web.config]
<configuration>
<appSettings>
<add key="ABC.Test" value="http://www.mywebsitee.com//WebServices/Test.asmx"/>
</appSettings>

[default.aspx]
Sub gv_Clients_Load()
    Dim ws As New ABC.Test      <---- Error here, see msg below
    gv_Clients.DataSource = ws.GetClients
    gv_Clients.DataBind()
End Sub

[default.aspx      Error Message]
Compiler Error Message: BC30002: Type 'ABC.Test' is not defined.


0
MikeCombe
Asked:
MikeCombe
  • 3
  • 3
1 Solution
 
strickddCommented:
To call a web service, you need a proxy class of some sort. To easily do this, you should add a web reference to that web service URL you posted. Then you can instantiate an object of that type as you have in your code.

On another not, to reference something in the web.config appSettings section, it is like this:

System.Configuration.ConfigurationManager.AppSettings["ABC.Test"]
0
 
MikeCombeAuthor Commented:
>>>>>>>>>>>>>>>>>>>>>>>>>>
To easily do this, you should add a web reference to that web service URL you posted.
<<<<<<<<<<<<<<<<<<<<<<<<<<

How do I do this ?
0
 
MikeCombeAuthor Commented:
>>>>>>>>>>>>>>>>>>>>>>>>>>
On another not, to reference something in the web.config appSettings section, it is like this:
System.Configuration.ConfigurationManager.AppSettings["ABC.Test"]
<<<<<<<<<<<<<<<<<<<<<<<<<<

changing......

[default.aspx]
Sub gv_Clients_Load()
    dim ws as New System.Configuration.ConfigurationManager.AppSettings("ABC.Test")
    gv_Clients.DataSource = ws.GetClients
    gv_Clients.DataBind()
End Sub

error;;;;;;

Compiler Error Message: BC30002: Type 'System.Configuration.ConfigurationManager.AppSettings' is not defined.
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!

 
strickddCommented:
If you right click on your project or website and Add Web Reference, follow the wizard, and VS will create the proxy class. Make sure to call the web reference ABC.Test and your code will then look like:

dim ws as New ABC.Text()

The "System.Configuration.ConfigurationManager.AppSettings("ABC.Test")" line of code was merely to show you how to reference a value from the appSettings, you cannot instantiate and object from a string key.
0
 
MikeCombeAuthor Commented:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
If you right click on your project or website and Add Web Reference, follow the wizard, and VS will create the proxy class. Make sure to call the web reference ABC.Test and your code will then look like:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

I understand what you are saying......but I don't want to use VS to build my project.
I am trying to find the code that I need to run my asmx file.
I should be able to hand-code without VS.
0
 
strickddCommented:
Is there a reason for not using VS? Licensing? Operating system? What?

If you want to call the web service then, you will need to create your own proxy class to call the web service and interact with it that way. If you can use other tools to create the proxy, you can follow the first half of this: http://msdn.microsoft.com/en-us/library/ms155134.aspx.

Other than that, you can create the XML manually through string builders and post that directly to the server, but you lose all the typed objects/properties and have to parse the XML return manually.

What exactly are you trying to achieve?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now