what's wrong with my code ?

P

pronto

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
 
G

Girish bharadwaj

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 said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top