Results 1 to 10 of 10

Thread: Web Service in a sub directory

  1. #1

    Thread Starter
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Web Service in a sub directory

    Ok I've created a web service and I've published the web service so that i have a precompiled app file. And on the server, I've created an IIS virtual directory called \ws\.

    When i have the service in the root directory, i can access the .asmx file and run the service just fine, but when i drop it down to the sub directory (\ws\AssociatesWebService) i get an error.

    Code:
    Server Error in '/WS' Application.
    --------------------------------------------------------------------------------
    
    Parser Error 
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
    
    Parser Error Message: Could not create type 'AssociateInformation'.
    
    Source Error: 
    
    
    Line 1:  <%@ WebService Language="vb" CodeBehind="/bin/App_Code/AssociateInformation.vb" Class="AssociateInformation" %>
    
     
    
    Source File: /ws/AssociatesWebService/AssociateInfo.asmx    Line: 1
    I'm assuming that i could turn this sub directory into another virtual directory but i'd rather not have to do that every time i have a new web service to deploy. Is there anyway around having to do that?

    Thanks S_M
    Last edited by space_monkey; Feb 5th, 2008 at 10:54 AM.
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: Web Service in a sub directory

    I'm assuming you, effectively, moved everything into the sub-directory - including the App_Code? If so, the issue is caused by the fact that the CodeBehind attribute is directing ASP.NET to load a type from the application root's bin/App_Code directory.

    Try changing the CodeBehind attribute to include your sub directory's path, i.e. /ws/AssociatesWebService/bin/App_Code, or move the code [AssociateInformation.vb] to the application root's bin/App_Code folder.

  3. #3

    Thread Starter
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: Web Service in a sub directory

    Quote Originally Posted by axion_sa
    I'm assuming you, effectively, moved everything into the sub-directory - including the App_Code? If so, the issue is caused by the fact that the CodeBehind attribute is directing ASP.NET to load a type from the application root's bin/App_Code directory.

    Try changing the CodeBehind attribute to include your sub directory's path, i.e. /ws/AssociatesWebService/bin/App_Code, or move the code [AssociateInformation.vb] to the application root's bin/App_Code folder.
    Yeah everything got moved, and you're correct the issue is caused by the asmx page pointing to the root application directory. If i move the bin folder up everything works fine.

    Will there be problems if i try to use this root directory to hold other web services? Seeing as how the name for the bin folder and the sub files are all the same, figure that they will overwrite each other. I had the thought that i could version the dlls differently for each individual web service but what kind of hell would that cause for the poor guy who works on this after me.

    I also tried providing the proper path for the codebehind but i still received the same error. I tried several versions but none seemed to work.

    Code:
    <%@ WebService Language="vb" CodeBehind="/ws/AssociatesWebService/bin/App_Code/AssociateInformation.vb" Class="AssociateInformation" %>
    
    <%@ WebService Language="vb" CodeBehind="~/ws/AssociatesWebService/bin/App_Code/AssociateInformation.vb" Class="AssociateInformation" %>
    
    <%@ WebService Language="vb" CodeBehind="~/AssociatesWebService/bin/App_Code/AssociateInformation.vb" Class="AssociateInformation" %>
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  4. #4
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: Web Service in a sub directory

    Seems you could also use sub-directories within the App_Code folder: http://dotnetjunkies.com/QuickStartv...ages/code.aspx

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Web Service in a sub directory

    Why not just have the ASMX's codebehind with the ASMX? The app_code folder is meant for classes, so you can move your logic out into classes there, but leave the rest alone.

  6. #6

    Thread Starter
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: Web Service in a sub directory

    Its seems like the default codebehind for the webservice is stored as a class in the app_code (just .vb) rather than as an asmx.vb file....
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Web Service in a sub directory

    How odd, I can't seem to replicate that. Tried it on VS 2005/2.0, unless the OP is actually using something else.

  8. #8

    Thread Starter
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: Web Service in a sub directory

    nope I'm using VS 2005/2.0 as well... When i get into work I'll take a look and see if i have some weird setting changed but i don't think i do.
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Web Service in a sub directory

    Oh, you're the OP. That's probably the reason it's happening.

    (Keep us posted) (pun unintended)

  10. #10

    Thread Starter
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: Web Service in a sub directory

    Here's what I've ended up with.

    I went back to my web service solution and added a new web service item to it. When I was creating the web service, I unchecked the option that says "Place code in separate file". Soooo all my code is stored in the asmx file. In my \ws\ dir i place my asmx file into a sub folder and my classes in the app_code folder in the root directory. And everything works. Though I'm not sure i even need the sub directory now.

    I don't know if I'm entirely happy with it but unless there is a reason not to do it or until i can figure out why my code behind is getting split off like it was; I guess I'll have to settle.

    I appreciate the help.
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width