2

I have made a ASP.net Web Service which contains a service which takes no parameters. I would like to invoke the ASMX service directly from a URL query.

This is my service

[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public DataSet getXMLData()
{
    string strQuery = "SELECT  * FROM Products";
    string strRootNode = "Root";
    string strItemNode = "Item";

    dbConn = dbConnString;
    dbQuery = strQuery;
    .
    .
    .
    .
    da.Fill(ds, strItemNode);
    return ds;
}

This doesn't work

http://localhost:23147/ProductsWS.asmx?op=getXMLData

The page debug page for the service is displayed but it isn't invoked. I would like to be automatically invoked such that the query returns:

<Root xmlns="">
    <Item diffgr:id="Item1" msdata:rowOrder="0">
        <ModelName>Tree</ModelName> 
        <UnitCost>7.0000</UnitCost> 
    </Item>
    <Item diffgr:id="Item2" msdata:rowOrder="1">
        <ModelName>Stump</ModelName> 
        <UnitCost>13.0200</UnitCost> 
    </Item>
</Root>

How would I go about doing this?

8
  • First of all, which version of .NET are you using? If you're using .NET 3.0 or above, then you should not be creating ASMX web services at all. You should be using WCF instead. Second of all, please be more clear about what you're asking. What do you mean "passing one (1) URL"? What do you mean by "the xml file for the service"? Do you mean the WSDL? Commented Mar 8, 2012 at 0:47
  • Thanks for your response. Post updated to clarify Commented Mar 8, 2012 at 0:53
  • You haven't answered my questions. What are you trying to accomplish? Can you post the code of the services? Commented Mar 8, 2012 at 1:04
  • Sry. Further clarified. Using .Net 4.0 Commented Mar 8, 2012 at 1:21
  • What happens if you just display the help page, then click on the getXmlData operation and submit it? Does it work? If so, then the URL it uses is the URL you need to use for the service. Also, you haven't said what "doesn't work" means. Commented Mar 8, 2012 at 1:24

1 Answer 1

3

This is the URL for calling your service:

http://localhost:23147/ProductsWS.asmx/getXMLData
Sign up to request clarification or add additional context in comments.

1 Comment

Good catch. I didn't even notice he was using the wrong operation name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.