null parameters problem

Rafael Llarena <[email protected]>
Newsgroups gmane.comp.web.services.general
Message-ID <[email protected]>
Hi,

I’m developping a web service in C# and a client in eVC++ (for a Pocket 
PC). My problem is in the web service. I use PocketSoap to create a SOAP 
request in the client and send it to the web service. When the request 
arrives at the WS the correct method execution begins, but whatever 
parameter I send it always arrives as null (or 0 if it’s an integer). 
But I’ve monitored traffic and examined the SOAP packet contents and 
they seem to be correct (the correct parameter’s value is there). So I 
don’t understand why, sending a correct SOAP packet to the correct web 
service method, it always executes with null parameters. When I try with 
the test form (via HTTP POST) it does work

Here’s the code

WEB SERVICE

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Diagnostics;

using System.Web;

using System.Web.Services;

namespace WebService1

{

/// <summary>

/// Descripción breve de Service1.

/// </summary>

[WebService(Namespace="http://tempuri.org/test1/Service1")]

public class Service1 : System.Web.Services.WebService

{

public Service1()

{

//CODEGEN: llamada necesaria para el Diseñador de servicios Web ASP .NET

InitializeComponent();

}

[WebMethod]

public string testMethod(int param)

{

string s = "Result " + param;

return s;

}

}

}

CLIENT (eVC++)

BOOL callWebService()

{

CComVariant resVal ;

CComPtr<ISOAPNode> prm ;

CComPtr<IHTTPTransportAdv> pt ;

CComBSTR req ;

CComPtr<ISOAPNodes> params ;

CComPtr<ISOAPEnvelope> penv ;

HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED );

int x = 5;

_HR( CoCreateInstance(__uuidof(CoEnvelope), NULL, CLSCTX_INPROC, 
__uuidof(ISOAPEnvelope),(void **)&penv ) );

_HR( penv->put_MethodName ( CComBSTR(OLESTR("testMethod")) ) );

_HR( penv->put_URI ( 
CComBSTR(OLESTR("http://tempuri.org/test1/Service1/")) ) );

_HR( penv->get_Parameters(&params) );

_HR( params->Create ( CComBSTR(OLESTR("param")), CComVariant(x), NULL, 
NULL, NULL, NULL ) ) ;

_HR( penv->Serialize(&req) );

_HR( pt.CoCreateInstance( __uuidof(HTTPTransport) ) );

_HR( pt->put_SOAPAction( 
CComBSTR(OLESTR("http://tempuri.org/testMethod"))) );

_HR( pt->Send ( 
CComBSTR(OLESTR("http://host:port/test1/Service1.asmx")), req ) );

req.Empty() ;

_HR( penv->Parse(CComVariant(pt), NULL) ) ;

params.Release() ;

_HR( penv->get_Parameters(&params) ) ;

_HR( params->get_Item(0, &prm) ) ;

_HR( prm->get_Value(&resVal) ) ;

resVal.ChangeType(VT_BSTR) ;

AfxMessageBox(CString (resVal.bstrVal),MB_OK);

}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.