W3C home > Mailing lists > Public > www-ws@w3.org > February 2005

null parameters problem

From: Rafael Llarena <rafallg@ono.com>
Date: Mon, 28 Feb 2005 18:01:03 +0100
Message-ID: <42234E4F.4040408@ono.com>
To: www-ws@w3.org

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);

}
Received on Monday, 28 February 2005 19:52:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 July 2007 12:25:48 GMT