java gsoap_JAVA Client call gSOAP server

Hi,

I am trying to write a java client (using Axis) to call a webservice

written in C++ using gsoap.

I am passing a string of type "String" through the java client. At

the gsoap the declaration is "char ".

Surprisingly, values in c++ webservice are coming null even though I

am passing some value from the java client. Please let me know what

could be the reason.

I am not getting any exception at Java client side. The C++ web service is

in the form of a CGI.

Here is the some part of the C++ web service and the Java client.

final String endPoint = "http://abc.xyz.com/Profile.cgi";

final String AddMethod = "AddBuyer";

String AddNewBuyerProfile( String name1Str,

String name2Str,

String address1Str,

String cityStr,

String stateStr,

String countryStr,

String postalCodeStr,

String emailStr,

String telephoneStr,

String accessNameStr,

String genderStr,

String challengeQStr ,

String challengeAStr )

{

String errorStr = "";

int errorCode = 99;

int result = 99;

try

{

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new java.net.URL(endPoint) );

call.setOperationName(new QName("http://tempuri.org/ns1.xsd", AddMethod));

call.removeAllParameters();

call.addParameter("name1_str", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); //1

call.addParameter("name2_str", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); //2

....

....

call.setReturnType(org.apache.axis.Constants.XSD_INTEGER);

String retStr = (String) call.invoke( new Object[] {

name1Str, //1

name2Str, //2

address1Str, //3

cityStr, //4

stateStr, //5

countryStr, //6

postalCodeStr, //7

emailStr, //8

telephoneStr, //9

accessNameStr, //10

genderStr, //11

challengeQStr , //12

challengeQStr , //13

result //14

} ) ;

System.out.println("The response is '" retStr"'");

int result1 = Integer.parseInt(retStr.trim());

if ( result1 == INITIALIZE_ERROR)

{

errorStr = "Initialization Error. Addition of new buyer failed !!";

}

else

if ( result1 == ADD_ERROR )

{

errorStr = "Addition of new buyer failed !!";

}

else

if ( result1 == SUCCESS_CODE )

{

errorStr = "Addition of new buyer successful !!";

}

}

catch (Exception e)

{

errorStr = e.toString();

}

return errorStr;

}

AND at the web service declaration is

cat INC/Server.htypedef char *xsd__string; // encode xsd__string value as the xsd:string schema type

//gsoap ns1 service location: http://abc.xyz.com/Profile.cgi

int ns1__AddBuyer(xsd__string name1_str, xsd__string name2_str, xsd__string address1_str,xsd__string city_str, xsd__string state_str, xsd__string country_str, xsd__string postalCode_str, xsd__string email_str, xsd__string telephone_str, xsd__string accessName_str, xsd__string gender_char, xsd__string challenge_q, xsd__string challenge_a, int&result);

and the webservice implementation ...

#include "soapH.h" /include generated proxy and SOAP support/

#include "ns1.nsmap"

#include "MainDriver.h"

int main()

{

soap_serve(soap_new()); use the remote method request dispatcher

//or alternatively,

//struct soap soap;

//soap_init(&soap);

//soap_serve(&soap);

}

int ns1__AddBuyer(struct soap soap, char *name1_str, char *name2_str, char *address1_str,char *city_str, char *state_str, char *country_str, char *postalCode_str, char *email_str, char *telephone_str, char *accessName_str, chargender_char, char challenge_q, char *challenge_a, int&result)

{

cout << telephone_str << endl;

............

}

and the ns1.nsmap is

cat ns1.nsmap

#include "soapH.h"

SOAP_NMAC struct Namespace namespaces[] =

{

{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org//soap-envelope", NULL},

{"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org//soap-encoding", NULL},

{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org//XMLSchema-instance", NULL},

{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org//XMLSchema", NULL},

{"ns1", "http://tempuri.org/ns1.xsd", NULL, NULL},

{NULL, NULL, NULL, NULL}

};

I appreciate any suggestion to overcome this problem.

Thanks.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值