Hello:
Created a simple java class called DocLit1 with the following method:
public String testString(String str1, String str2){
System.out.println(" str 1 is " + str1);
System.out.println(" str2 is " + str2);
return str1 + str2;
}
Deployed it as document/literal (NOT WRAPPED )
When the input values are {"str1", "str2") the response is str1null. On
further investigation found out that the second parameter is always null.
I have attached the WSDL and my client code(DocLit1.java as dynamic
invocation) with this email. Would appreciate any pointers.
Even generated the stubs using the WSDL2JAVA and tried it but got the
same result. The client for the stub is DocLiteralClient.java.
Thanks,
Ravi
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="doclit1" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="doclit1" xmlns:intf="doclit1" xmlns:tns1="http://usertype.testing.samples" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.2
Built on May 03, 2005 (02:20:24 EDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://usertype.testing.samples" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="in0" type="xsd:string"/>
<element name="in1" type="xsd:string"/>
</schema>
<schema elementFormDefault="qualified" targetNamespace="doclit1" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="testStringReturn" type="xsd:string"/>
</schema>
</wsdl:types>
<wsdl:message name="testStringResponse">
<wsdl:part element="impl:testStringReturn" name="testStringReturn"/>
</wsdl:message>
<wsdl:message name="testStringRequest">
<wsdl:part element="tns1:in0" name="in0"/>
<wsdl:part element="tns1:in1" name="in1"/>
</wsdl:message>
<wsdl:portType name="doclit1">
<wsdl:operation name="testString" parameterOrder="in0 in1">
<wsdl:input message="impl:testStringRequest" name="testStringRequest"/>
<wsdl:output message="impl:testStringResponse" name="testStringResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="doclit1soapSoapBinding" type="impl:doclit1">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="testString">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="testStringRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="testStringResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="doclit1Service">
<wsdl:port binding="impl:doclit1soapSoapBinding" name="doclit1soap">
<wsdlsoap:address location="http://localhost:6415/axis/services/doclit1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
/*
* Created on Jul 8, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package doclit1;
/**
* @author ravik
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class DocliteralClient_AxisStubs {
public static void main(String[] args) throws Exception{
Doclit1Service service = new Doclit1ServiceLocator();
Doclit1 port = service.getdoclit1soap();
String result = port.testString("str1", "str2");
System.out.println(" result from docliteralclient is " + result);
}
}
import org.apache.axis.encoding.ser.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
public class Doclit1_dynamicinvocation {
public static void main(String[] args){
client2();
}
private static void client2(){
try{
String wsdlLocation = "http://localhost:6415/axis/services/doclit1?wsdl";
String targetNamespace = "doclit1";
String schemaNamespace = "http://usertype.testing.samples";
QName serviceName = new QName(targetNamespace, "doclit1Service");
QName portName = new QName(targetNamespace, "doclit1soap");
QName operationName = new QName("", "testString");
// create service
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress("http://localhost:6415/axis/services/doclit1");
call.setOperationName(operationName);
QName strQName = new QName("http://www.w3.org/2001/XMLSchema","string");
call.addParameter(new javax.xml.namespace.QName(schemaNamespace, "in0"), strQName, ParameterMode.IN);
call.addParameter(new javax.xml.namespace.QName(schemaNamespace, "in1"), strQName, ParameterMode.IN);
// return type
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
call.setReturnType(new javax.xml.namespace.QName(schemaNamespace, "in0"), String.class);
call.setReturnQName(new QName("doclit1", "testStringReturn"));
call.setOperationStyle(org.apache.axis.constants.Style.DOCUMENT);
call.setOperationUse(org.apache.axis.constants.Use.LITERAL);
call.setUseSOAPAction(true);
call.setSOAPActionURI("");
call.setEncodingStyle(null);
String result = (String)call.invoke(new Object[]{"str1","str2"});
System.out.println("Search Response: " + result);
}catch(Exception ex){
ex.printStackTrace();
}
}
}