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.
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
Cocould 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 = 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. h
Typedef 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_init (& soap );
// Soap_serve (& soap );
}
Int NS1 _ addbuyer (struct soapSoap, 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, charChallenge_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}
};
I appreciate any suggestion to overcome this problem.
Thanks.