I don't know if this is the correct forum to ask this question. But I have an asp.net web service with a method method GetCapital() as follows:
Forget the logic. I am calling this web service from a VC++ client using SOAP as follows:Code:[WebMethod] public string GetCapital( string inp ) { XmlTextReader reader = new XmlTextReader("c:\\Temp\\Sample.xml"); string ret =""; reader.MoveToContent(); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { // check if the element has any attributes if (reader.HasAttributes) { // move to the first attribute reader.MoveToFirstAttribute(); for (int i = 0; i < reader.AttributeCount; i++) { // read the current attribute reader.MoveToAttribute(i); if (reader.Value == inp) { ret = reader.GetAttribute(1); return ret; } } } } } return ret; } }
But when I call the GetCapital method from the client <i get the follwing error in the response :Code:std::string csSoapString; csSoapString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; csSoapString += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""; csSoapString += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance \""; csSoapString += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"; csSoapString += "<soap:Body>"; csSoapString += "<GetCapital xmlns=\"http://tempuri.org/\"/>"; csSoapString += "<inp xsi:type=\"xsd:string\">"; csSoapString += "USA"; csSoapString += "</inp>"; csSoapString += "</soap:Body>"; csSoapString += "</soap:Envelope>"; int nContentLength = csSoapString.length(); CString csLength; csLength.Format( _T( "%d" ),nContentLength ); char temp[10]; _itoa_s(csSoapString.size(), temp, 10, 10); string csSoapAction; csSoapAction = "Content-Type: text/xml; charset=utf-8"; csSoapAction += "Content-Length: "; csSoapAction += temp; csSoapAction += "\r\n\r\n"; csSoapAction += "SOAPAction: \""; csSoapAction += "http://tempuri.org/GetCapital"; csSoapAction += "\"\0\r\n\r\n"; BOOL bSent = HttpSendRequestA(hRequest, csSoapAction.c_str(), csSoapAction.size(), (LPVOID )csSoapString.c_str(), csSoapString.size());
The problem is the paramater "USA" I am passing from the client is not received in the web service. In the web service the input argument inp is null. What is wrong with the SOAP request ? How should I correct the SOAP request?Code:Object reference not set to an instance of object.
Thanks in advance.


Reply With Quote