what's wrong with my code ?

Discussion in 'ASP .Net Web Services' started by pronto, Sep 21, 2004.

  1. pronto

    pronto Guest

    Hi guys.

    I have follow C# code in my WebService.
    ---------------------------------------

    WebMethod (Description="Return current stock price")]
    public decimal GetQuote(string Symbol)
    {
    if(Symbol.ToLower() == "msft")
    return 55.0m;
    else if(Symbol.ToLower() == "intc")
    return 32.0m;
    else
    return 100.0m;
    }


    When I accessing it with IE, it shows me follow format to call.
    ---------------------------------------------------------------

    POST /WebServicesTest/WebService1/Service1.asmx HTTP/1.1
    Host: localhost
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/GetQuote"

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <GetQuote xmlns="http://tempuri.org/">
    <Symbol>string</Symbol>
    </GetQuote>
    </soap:Body>
    </soap:Envelope>


    Here is my C++ code using SOAP SDK.
    -----------------------------------

    void CallGetQuote()
    {
    ISoapSerializerPtr Serializer;
    ISoapReaderPtr Reader;
    ISoapConnectorPtr Connector;
    HRESULT hr;

    // Connect to the service.
    hr = Connector.CreateInstance(__uuidof(HttpConnector30));
    Connector->Property["EndPointURL"] =
    "http://HostName1/webservicesTest/WebService1/Service1.asmx";

    hr = Connector->Connect();

    Connector->Property ["SoapAction"] = "http://tempuri.org/GetQuote";
    Connector->BeginMessage();

    // Create the SoapSerializer object.
    hr = Serializer.CreateInstance(__uuidof(SoapSerializer30));

    // Connect the serializer object to the input stream of the connector
    object.
    hr = Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

    Serializer->StartEnvelope("","","");
    Serializer->StartBody("");

    Serializer->StartElement("GetQuote","","","");
    Serializer->StartElement("Symbol","","","");
    Serializer->WriteString("MSFT");
    Serializer->EndElement();
    Serializer->EndElement();

    Serializer->EndBody();
    Serializer->EndEnvelope();

    // Send the message to the XML Web service.
    Connector->EndMessage();

    // Read the response.
    Reader.CreateInstance(__uuidof(SoapReader30));

    // Connect the reader to the output stream of the connector object.
    Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");

    // Display the result.
    printf("Answer: %s\n", (const char*)Reader->RpcResult->text);
    printf("\n\nAnswer: %s\n", (const char*)Reader->RpcResult->xml);
    }


    AND HERE IS REPLY FROM SERVICE.
    -------------------------------
    Answer: soap:Server


    Answer: <faultcode>soap:Server</faultcode>



    WHAT AM I DOING WRONG ?

    thanx
    pronto, Sep 21, 2004
    #1
    1. Advertising

  2. I am not sure. But, you can do Request.SaveAs() on the server side and see
    what the request looks like. That might show you if the <soap> request is
    correct or not.

    --
    Girish Bharadwaj
    http://msmvps.com/gbvb
    "pronto" <> wrote in message
    news:...
    > Hi guys.
    >
    > I have follow C# code in my WebService.
    > ---------------------------------------
    >
    > WebMethod (Description="Return current stock price")]
    > public decimal GetQuote(string Symbol)
    > {
    > if(Symbol.ToLower() == "msft")
    > return 55.0m;
    > else if(Symbol.ToLower() == "intc")
    > return 32.0m;
    > else
    > return 100.0m;
    > }
    >
    >
    > When I accessing it with IE, it shows me follow format to call.
    > ---------------------------------------------------------------
    >
    > POST /WebServicesTest/WebService1/Service1.asmx HTTP/1.1
    > Host: localhost
    > Content-Type: text/xml; charset=utf-8
    > Content-Length: length
    > SOAPAction: "http://tempuri.org/GetQuote"
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    > <soap:Body>
    > <GetQuote xmlns="http://tempuri.org/">
    > <Symbol>string</Symbol>
    > </GetQuote>
    > </soap:Body>
    > </soap:Envelope>
    >
    >
    > Here is my C++ code using SOAP SDK.
    > -----------------------------------
    >
    > void CallGetQuote()
    > {
    > ISoapSerializerPtr Serializer;
    > ISoapReaderPtr Reader;
    > ISoapConnectorPtr Connector;
    > HRESULT hr;
    >
    > // Connect to the service.
    > hr = Connector.CreateInstance(__uuidof(HttpConnector30));
    > Connector->Property["EndPointURL"] =
    > "http://HostName1/webservicesTest/WebService1/Service1.asmx";
    >
    > hr = Connector->Connect();
    >
    > Connector->Property ["SoapAction"] = "http://tempuri.org/GetQuote";
    > Connector->BeginMessage();
    >
    > // Create the SoapSerializer object.
    > hr = Serializer.CreateInstance(__uuidof(SoapSerializer30));
    >
    > // Connect the serializer object to the input stream of the connector
    > object.
    > hr = Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
    >
    > Serializer->StartEnvelope("","","");
    > Serializer->StartBody("");
    >
    > Serializer->StartElement("GetQuote","","","");
    > Serializer->StartElement("Symbol","","","");
    > Serializer->WriteString("MSFT");
    > Serializer->EndElement();
    > Serializer->EndElement();
    >
    > Serializer->EndBody();
    > Serializer->EndEnvelope();
    >
    > // Send the message to the XML Web service.
    > Connector->EndMessage();
    >
    > // Read the response.
    > Reader.CreateInstance(__uuidof(SoapReader30));
    >
    > // Connect the reader to the output stream of the connector object.
    > Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
    >
    > // Display the result.
    > printf("Answer: %s\n", (const char*)Reader->RpcResult->text);
    > printf("\n\nAnswer: %s\n", (const char*)Reader->RpcResult->xml);
    > }
    >
    >
    > AND HERE IS REPLY FROM SERVICE.
    > -------------------------------
    > Answer: soap:Server
    >
    >
    > Answer: <faultcode>soap:Server</faultcode>
    >
    >
    >
    > WHAT AM I DOING WRONG ?
    >
    > thanx
    >
    >
    Girish bharadwaj, Sep 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    2,173
    Ralf Hildebrandt
    Sep 10, 2003
  2. willem oosthuizen

    What is wrong with the following code?

    willem oosthuizen, Oct 10, 2003, in forum: VHDL
    Replies:
    9
    Views:
    1,251
  3. Matthew
    Replies:
    7
    Views:
    654
    Priscilla Walmsley
    Jan 7, 2005
  4. David. E. Goble
    Replies:
    9
    Views:
    462
    David. E. Goble
    Feb 2, 2005
  5. kiran
    Replies:
    12
    Views:
    1,095
    Scott Sauyet
    Dec 7, 2011
Loading...

Share This Page