aspose file tools*
The moose likes Web Services and the fly likes Help needed in calling a Web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Help needed in calling a Web service " Watch "Help needed in calling a Web service " New topic
Author

Help needed in calling a Web service

Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
Hi,

I want to call a web service from my component. The called web service might have different names, therefore I don't want to use the proxy class way.

I am facing problem in parsing the input parameters from the wsdl file. I have attached the wsdl file at the end.

I am using the javax.wsdl.xml.WSDLReader(axis). I have been able to parse all the bindings, ports and messages but

1. i am not able to parse the wsdl:types to obtain the input parameters

//javax.wsdl.Operation op obtained from the port which alternatively obtained from Definition
Message inputs = op.getInput().getMessage();
Part part = null;
// let's find the input params
Map inputParts = inputs.getParts();
// create the object array which Axis will use to pass in the parameters
inputParams = new Object[inputParts.size()];
s = inputParts.keySet();
it = s.iterator();
int i = 0;


while(it.hasNext())
{
part = (Part) inputParts.get(it.next());
Afetr performing this, i have no clue as to how to parse the input parameters.

2. How will i generate the java Objects array from these input parameters to pass to the Call.invoke function, i.e.
Call call = (Call) service.createCall();
call.setOperation(portQN, operationName);
Object ret = (Integer) call.invoke(inputParams);
The function takes an object[] as input but since i have complex types involved in wsdl, so how will this object array needs to be populated


WSDL file:

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://V4_0.testcenter8" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax258="http://testcenter8.V4_0.testcenter8/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax257="http://V4_0.testcenter8/xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://V4_0.testcenter8">
<wsdl:types>
<xs:schema xmlns:ax260="http://V4_0.testcenter8/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://V4_0.testcenter8">
<xs:import namespace="http://V4_0.testcenter8/xsd" />
<xs:element name="executeRuleset">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="param0" nillable="true" type="ax257:testcenter8_V4_0_Req" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="executeRulesetResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax257:testcenter8_V4_0_Resp" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema xmlns:ax259="http://testcenter8.V4_0.testcenter8/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://V4_0.testcenter8/xsd">
<xs:import namespace="http://testcenter8.V4_0.testcenter8/xsd" />
<xs:complexType name="testcenter8_V4_0_Req">
<xs:sequence>
<xs:element minOccurs="0" name="cabinetName" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="inputsobj" nillable="true" type="ax258:Inputs" />
<xs:element minOccurs="0" name="loginReqd" type="xs:boolean" />
<xs:element minOccurs="0" name="outputsobj" nillable="true" type="ax258:Outputs" />
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="userName" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="testcenter8_V4_0_Resp">
<xs:sequence>
<xs:element minOccurs="0" name="inputsobj" nillable="true" type="ax258:Inputs" />
<xs:element minOccurs="0" name="outputsobj" nillable="true" type="ax258:Outputs" />
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://testcenter8.V4_0.testcenter8/xsd">
<xs:complexType name="Inputs">
<xs:sequence>
<xs:element minOccurs="0" name="description" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="subject" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Outputs">
<xs:sequence>
<xs:element minOccurs="0" name="category" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="massRequestType" type="xs:int" />
<xs:element minOccurs="0" name="subCategory" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="executeRulesetRequest">
<wsdl:part name="parameters" element="ns:executeRuleset" />
</wsdl:message>
<wsdl:message name="executeRulesetResponse">
<wsdl:part name="parameters" element="ns:executeRulesetResponse" />
</wsdl:message>
<wsdl:portType name="testcenter8_V4_0WebServicePortType">
<wsdlperation name="executeRuleset">
<wsdl:input message="ns:executeRulesetRequest" wsaw:Action="urn:executeRuleset" />
<wsdlutput message="ns:executeRulesetResponse" wsaw:Action="urn:executeRulesetResponse" />
</wsdlperation>
</wsdl:portType>
<wsdl:binding name="testcenter8_V4_0WebServiceSoap11Binding" type="ns:testcenter8_V4_0WebServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdlperation name="executeRuleset">
<soapperation soapAction="urn:executeRuleset" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:binding name="testcenter8_V4_0WebServiceSoap12Binding" type="ns:testcenter8_V4_0WebServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdlperation name="executeRuleset">
<soap12peration soapAction="urn:executeRuleset" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:binding name="testcenter8_V4_0WebServiceHttpBinding" type="ns:testcenter8_V4_0WebServicePortType">
<http:binding verb="POST" />
<wsdlperation name="executeRuleset">
<httpperation location="testcenter8_V4_0WebService/executeRuleset" />
<wsdl:input>
<mime:content type="text/xml" part="executeRuleset" />
</wsdl:input>
<wsdlutput>
<mime:content type="text/xml" part="executeRuleset" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:service name="testcenter8_V4_0WebService">
<wsdl:port name="testcenter8_V4_0WebServiceHttpSoap11Endpoint" binding="ns:testcenter8_V4_0WebServiceSoap11Binding">
<soap:address location="http://192.168.56.89:8080/axis2/services/testcenter8_V4_0WebService.testcenter8_V4_0WebServiceHttpSoap11Endpoint/" />
</wsdl:port>
<wsdl:port name="testcenter8_V4_0WebServiceHttpSoap12Endpoint" binding="ns:testcenter8_V4_0WebServiceSoap12Binding">
<soap12:address location="http://192.168.56.89:8080/axis2/services/testcenter8_V4_0WebService.testcenter8_V4_0WebServiceHttpSoap12Endpoint/" />
</wsdl:port>
<wsdl:port name="testcenter8_V4_0WebServiceHttpEndpoint" binding="ns:testcenter8_V4_0WebServiceHttpBinding">
<http:address location="http://192.168.56.89:8080/axis2/services/testcenter8_V4_0WebService.testcenter8_V4_0WebServiceHttpEndpoint/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Regards

Nitin
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
An update -

I want to call a web service from my component. The called web service might have different names, therefore I don't want to use the proxy class way.
I am parsing the WSDL file and obtaining the different parameters. But i am having problem in passing the parameters(receiving as well) to the web service and i am not able to find any good refernce on the internet, i am getting the following exception:

org.xml.sax.SAXException: Invalid element in javax.xml.rpc.namespace.QName - inputsobj
at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(Unknown Source)
at org.apache.axis.AxisFault.makeFault(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(Unknown Source)
at org.apache.axis.message.SAX2EventRecorder.replay(Unknown Source)
at org.apache.axis.message.MessageElement.publishToHandler(Unknown Source)
at org.apache.axis.client.Call.invoke(Unknown Source)
at org.apache.axis.message.RPCElement.deserialize(Unknown Source)
at org.apache.axis.message.RPCElement.getParams(Unknown Source)
at org.apache.axis.client.Call.invoke(Unknown Source)
at org.apache.axis.client.Call.invoke(Unknown Source)
at org.apache.axis.client.Call.invoke(Unknown Source)
at org.apache.axis.client.Call.invoke(Unknown Source)
at javaapplication17.Invoke.axisInvoke(Invoke.java:639)
at javaapplication17.Invoke.parseWSDL(Invoke.java:423)
at javaapplication17.Invoke.run(Invoke.java:76)
at javaapplication17.Invoke.main(Invoke.java:64)
at org.apache.axis.client.Call.invoke(Unknown Source)
Error invoking service : org.xml.sax.SAXException: Invalid element in javax.xml.rpc.namespace.QName - inputsobj
at javaapplication17.Invoke.axisInvoke(Invoke.java:639)
at javaapplication17.Invoke.parseWSDL(Invoke.java:423)
at javaapplication17.Invoke.run(Invoke.java:76)
at javaapplication17.Invoke.main(Invoke.java:64)
Caused by: org.xml.sax.SAXException: Invalid element in javax.xml.rpc.namespace.QName - inputsobj
at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(Unknown Source)
at org.apache.axis.message.SAX2EventRecorder.replay(Unknown Source)
at org.apache.axis.message.MessageElement.publishToHandler(Unknown Source)
at org.apache.axis.message.RPCElement.deserialize(Unknown Source)
at org.apache.axis.message.RPCElement.getParams(Unknown Source)
... 7 more

Following is the code snippet and the passed values to the function:

Parameters passed to the test function:
targetNamespace = "http://V5_0.testcenter8"
serviceName = "testcenter8_V5_0WebServiceHttpSoap11Endpoint"
portName = "http://V5_0.testcenter8:testcenter8_V5_0WebService"
operationName = "executeRuleset"
arrListParameters; //obtained by parsing the XSD using XMLSchema(XSD created from wsdl types tag)
implURI = "http://192.168.56.89:8080/axis2/services/testcenter8_V5_0WebService?wsdl"


test function:
NOTE:some things have been hardcoded.

public void axisInvoke(String targetNamespace, String serviceName, String portName,
String operationName, ArrayList<Parameter> arrListParameters, String implURI)
{
try
{
// first, due to a funny Axis idiosyncracy we must strip portName of
// it's target namespace so we can pass it in as targetNamespace, localPart
int index = portName.indexOf(":", portName.indexOf("http://") + new String("http://").length());
String portNamespace = portName.substring(0, index);
portName = portName.substring(index == 0 ? index : index + 1); // to strip the :

javax.xml.rpc.namespace.QName serviceQN = new javax.xml.rpc.namespace.QName(portNamespace, portName);

org.apache.axis.client.Service service = new org.apache.axis.client.Service(new URL(implURI), serviceQN);

javax.xml.rpc.namespace.QName portQN = new javax.xml.rpc.namespace.QName(targetNamespace, serviceName);

// This Call object will be used the invocation
Call call = (Call) service.createCall();
// Now make the call...
System.out.println("Invoking service >> " + serviceName + " <<...");
//call.setOperation(portQN, operationName); //do not work
call.setOperationName(new javax.xml.rpc.namespace.QName("http://V5_0.testcenter8", "executeRuleset"));


call.removeAllParameters();// why there is parameters already added to the list of parameters
//call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
ArrayList<Object> arrListInputParameters = new ArrayList<Object>();
for(int i = 0; i < arrListParameters.size(); i++)
{
String strParamName = arrListParameters.get(i).strParamName;
String strParamType = arrListParameters.get(i).strParamType;
String strNameSpaceURI = arrListParameters.get(i).strParamNameSpaceURI;
if(strNameSpaceURI.compareToIgnoreCase("http://www.w3.org/2001/XMLSchema") == 0)
{
boolean isInParam = true;
if(strParamName.compareToIgnoreCase("cabinetName") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add("testcenter8");
}
else if(strParamName.compareToIgnoreCase("loginReqd") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_BOOLEAN, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add(false);
}
else if(strParamName.compareToIgnoreCase("password") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add("D@nger0us");
}
else if(strParamName.compareToIgnoreCase("userName") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add("sanjeev");
}
else if(strParamName.compareToIgnoreCase("description") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add("Change Address");
}
else if(strParamName.compareToIgnoreCase("subject") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add("Credit Card");
}
else if(strParamName.compareToIgnoreCase("category") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add("");
isInParam = false;
}
else if(strParamName.compareToIgnoreCase("massRequestType") == 0)
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_INTEGER, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add((int) 1);
isInParam = false;
}
else
{
call.addParameter(new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
arrListInputParameters.add("");
isInParam = false;
}
/*if(isInParam)
{
call.addParameter(strParamName, org.apache.axis.Constants.XSD_STRING, ParameterMode.PARAM_MODE_INOUT);
//call.addParameter(strParamName, new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), ParameterMode.PARAM_MODE_INOUT);
}
else
{
call.addParameter(strParamName, new javax.xml.rpc.namespace.QName(strNameSpaceURI, strParamName), ParameterMode.PARAM_MODE_INOUT);
}*/


}
}

/*inputParams = new Object[arrListInputParameters.size() + 1];
inputParams[0] = "";
for(int i = 1; i <= arrListInputParameters.size(); i++)
{
inputParams[i] = arrListInputParameters.get(i - 1);
}*/

inputParams = new Object[arrListInputParameters.size()];
for(int i = 0; i < arrListInputParameters.size(); i++)
{
inputParams[i] = arrListInputParameters.get(i);
}

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

//call.setReturnType(org.apache.axis.Constants.XSD_ANYTYPE);
call.setTargetEndpointAddress(new URL("http://192.168.56.89:8080/axis2/services/testcenter8_V5_0WebService.testcenter8_V5_0WebServiceHttpSoap11Endpoint"));


Object ret = call.invoke(inputParams);

System.out.println("Result returned from call to " + serviceName + " -- " + ret);
System.out.println("Finished");
}
catch(java.net.MalformedURLException e)
{
System.out.println("Error invoking service : " + e);
e.printStackTrace();
}
catch(javax.xml.rpc.ServiceException e2)
{
System.out.println("Error invoking service : " + e2);
e2.printStackTrace();
}
catch(java.rmi.RemoteException e3)
{
System.out.println("Error invoking service : " + e3);
e3.printStackTrace();
}
}



WSDL file:

WSDL file:

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://V4_0.testcenter8" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax258="http://testcenter8.V4_0.testcenter8/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax257="http://V4_0.testcenter8/xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://V4_0.testcenter8">
<wsdl:types>
<xs:schema xmlns:ax260="http://V4_0.testcenter8/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://V4_0.testcenter8">
<xs:import namespace="http://V4_0.testcenter8/xsd" />
<xs:element name="executeRuleset">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="param0" nillable="true" type="ax257:testcenter8_V4_0_Req" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="executeRulesetResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax257:testcenter8_V4_0_Resp" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema xmlns:ax259="http://testcenter8.V4_0.testcenter8/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://V4_0.testcenter8/xsd">
<xs:import namespace="http://testcenter8.V4_0.testcenter8/xsd" />
<xs:complexType name="testcenter8_V4_0_Req">
<xs:sequence>
<xs:element minOccurs="0" name="cabinetName" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="inputsobj" nillable="true" type="ax258:Inputs" />
<xs:element minOccurs="0" name="loginReqd" type="xs:boolean" />
<xs:element minOccurs="0" name="outputsobj" nillable="true" type="ax258:Outputs" />
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="userName" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="testcenter8_V4_0_Resp">
<xs:sequence>
<xs:element minOccurs="0" name="inputsobj" nillable="true" type="ax258:Inputs" />
<xs:element minOccurs="0" name="outputsobj" nillable="true" type="ax258:Outputs" />
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://testcenter8.V4_0.testcenter8/xsd">
<xs:complexType name="Inputs">
<xs:sequence>
<xs:element minOccurs="0" name="description" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="subject" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Outputs">
<xs:sequence>
<xs:element minOccurs="0" name="category" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="massRequestType" type="xs:int" />
<xs:element minOccurs="0" name="subCategory" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="executeRulesetRequest">
<wsdl:part name="parameters" element="ns:executeRuleset" />
</wsdl:message>
<wsdl:message name="executeRulesetResponse">
<wsdl:part name="parameters" element="ns:executeRulesetResponse" />
</wsdl:message>
<wsdl:portType name="testcenter8_V4_0WebServicePortType">
<wsdlperation name="executeRuleset">
<wsdl:input message="ns:executeRulesetRequest" wsaw:Action="urn:executeRuleset" />
<wsdlutput message="ns:executeRulesetResponse" wsaw:Action="urn:executeRulesetResponse" />
</wsdlperation>
</wsdl:portType>
<wsdl:binding name="testcenter8_V4_0WebServiceSoap11Binding" type="ns:testcenter8_V4_0WebServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdlperation name="executeRuleset">
<soapperation soapAction="urn:executeRuleset" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:binding name="testcenter8_V4_0WebServiceSoap12Binding" type="ns:testcenter8_V4_0WebServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdlperation name="executeRuleset">
<soap12peration soapAction="urn:executeRuleset" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdlutput>
<soap12:body use="literal" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:binding name="testcenter8_V4_0WebServiceHttpBinding" type="ns:testcenter8_V4_0WebServicePortType">
<http:binding verb="POST" />
<wsdlperation name="executeRuleset">
<httpperation location="testcenter8_V4_0WebService/executeRuleset" />
<wsdl:input>
<mime:content type="text/xml" part="executeRuleset" />
</wsdl:input>
<wsdlutput>
<mime:content type="text/xml" part="executeRuleset" />
</wsdlutput>
</wsdlperation>
</wsdl:binding>
<wsdl:service name="testcenter8_V4_0WebService">
<wsdl:port name="testcenter8_V4_0WebServiceHttpSoap11Endpoint" binding="ns:testcenter8_V4_0WebServiceSoap11Binding">
<soap:address location="http://192.168.56.89:8080/axis2/services/testcenter8_V4_0WebService.testcenter8_V4_0WebServiceHttpSoap11Endpoint/" />
</wsdl:port>
<wsdl:port name="testcenter8_V4_0WebServiceHttpSoap12Endpoint" binding="ns:testcenter8_V4_0WebServiceSoap12Binding">
<soap12:address location="http://192.168.56.89:8080/axis2/services/testcenter8_V4_0WebService.testcenter8_V4_0WebServiceHttpSoap12Endpoint/" />
</wsdl:port>
<wsdl:port name="testcenter8_V4_0WebServiceHttpEndpoint" binding="ns:testcenter8_V4_0WebServiceHttpBinding">
<http:address location="http://192.168.56.89:8080/axis2/services/testcenter8_V4_0WebService.testcenter8_V4_0WebServiceHttpEndpoint/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 544
    
    3
What is the deal here: the parameters you seem to pass all have V5_0 whereas your wsdl has them all shown as V4_0? It's hard to go on reading before you clarify the secret of it.
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
g tsuji wrote:What is the deal here: the parameters you seem to pass all have V5_0 whereas your wsdl has them all shown as V4_0? It's hard to go on reading before you clarify the secret of it.


Hi,

I am using V5_0 parameters only. Only mistakenly generated the XMLs as V4_0.

Regards

Nitin
Vinod Tiwari
Ranch Hand

Joined: Feb 06, 2008
Posts: 466
    
    1

Can you format the code? Its not readable, I think the issue could be due to namespace.


Vinod Tiwari | Twitter | Shikshanirman | Guftgu
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
wsdl file:
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
To add: there are 9 parameters added to the call object in the loop, is something(name of parameters, namespace etc) wrong here???(i could not find any reference how to do this)

cabinetName string http://www.w3.org/2001/XMLSchema
loginReqd boolean http://www.w3.org/2001/XMLSchema
password string http://www.w3.org/2001/XMLSchema
userName string http://www.w3.org/2001/XMLSchema
description string http://www.w3.org/2001/XMLSchema
subject string http://www.w3.org/2001/XMLSchema
category string http://www.w3.org/2001/XMLSchema
massRequestType int http://www.w3.org/2001/XMLSchema
subCategory string http://www.w3.org/2001/XMLSchema
Hikari Shidou
Ranch Hand

Joined: Jan 22, 2013
Posts: 88
Why have all that trouble because of a single WSDL?

Get Eclipse to handle Axis2 and provide you a Stub class, and consume it. You can go to WebService's /services/ folder to have a human readable description of operations and look for them in the Stub class and you're good to go. You don't even need to look on the WSDL.
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
I am thorough the proxy classes method already, first i tried it with wsimport util and then with netbeans IDE to generate the stub classes. After generating the stub classes some re-engineering is required to know what to do to call the service and pass the input parameters....

but however my application requires the dynamic invocation.
1. The application is supposed to understand what methods and input parameters the web service expects.
2. Present a user interface for configuration at run time. i.e. mapping input parameters etc. Note: i might decide to map a different web service at run time.
3. Call the web service and obtain the ouput.
4. Process the output.

re-generate stub classes and change references, re-engineer and recompile is not feasible for a dynamic application like this.....
Hikari Shidou
Ranch Hand

Joined: Jan 22, 2013
Posts: 88
You mean you need to regenerate stub classes without rebuilding your software? Why that? Is that WebService changing so often? That's troubling...

If it's changing, it should have some version control over which you can know what to expect, instead of processing whole WSDL every time.

Other than that, everything else you said is trivial. You UI receives parameters, process them into a JavaBean, you feed your interfacing object with it and this object translates this bean into parameters your stub expects, and call the stub operation.

Your interfacing object's class must undertand each possible version of the WebService. For each version, you have a stub class. In the worse scenario, you'll create a code to verify on WebService what version it's using ATM, then your interfacing object gets the related stub object and consumes it. If it's a new version you still don't support, you'll need to update your software, but once supported it will be forever.

You really need to talk with your WebService provider and tell him to keep a stable SOAP interface. He can refactor his server as he wants, but the interface must not change so after, even more at the point of client needing to parse WSDL and adapt to it every time!
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
You mean you need to regenerate stub classes without rebuilding your software? Why that? Is that WebService changing so often? That's troubling...
As i said, it is not feasible, i do not want to generate any stub classes and reference them.
Yes, web service can change, this is the way the application needs to work. my application will present a GUI for configuring purposes, the mappings will then be stored. I can have n number of web services to choose from to work with and hence the application can not rely on updating, it needs to dynamically adjust the web service for which the wsdl file is presented to it(through the GUI).

If it's changing, it should have some version control over which you can know what to expect, instead of processing whole WSDL every time.If I suppose you mean performance loss while parsing the wsdl file, then at run time i can cache the parsed parameters from the wsdl file so as to not parse it again if same is used again, i can bear some performance loss on this point....

Other than that, everything else you said is trivial. You UI receives parameters, process them into a JavaBean, you feed your interfacing object with it and this object translates this bean into parameters your stub expects, and call the stub operation.
Your interfacing object's class must undertand each possible version of the WebService. For each version, you have a stub class. In the worse scenario, you'll create a code to verify on WebService what version it's using ATM, then your interfacing object gets the related stub object and consumes it. If it's a new version you still don't support, you'll need to update your software, but once supported it will be forever.

As i explained above, choosing the web service is done at the run time, no subversions here, the web service can be entirely different and the mapping stuff will be done using the GUI(what parameters and which method).

You really need to talk with your WebService provider and tell him to keep a stable SOAP interface. He can refactor his server as he wants, but the interface must not change so after, even more at the point of client needing to parse WSDL and adapt to it every time!
I hope i could make myself clear that i need a generalized solution as oppose to a tightly coupled system(that will be a headache to my application to update it everytime).
Hikari Shidou
Ranch Hand

Joined: Jan 22, 2013
Posts: 88
As i said, it is not feasible, i do not want to generate any stub classes and reference them.
Yes, web service can change, this is the way the application needs to work. my application will present a GUI for configuring purposes, the mappings will then be stored.


It's still strange. WebService is meant to provide services. Configuring software should be more coupled to it than using WebService, and shouldn't need to change so often. I think you or the WebService provider should rethink its architecture.

If I suppose you mean performance loss while parsing the wsdl file, then at run time i can cache the parsed parameters from the wsdl file so as to not parse it again if same is used again, i can bear some performance loss on this point....


Not really. Parsing a WSDL, and any other non-enourmously-large XML takes a few milisecs.

I talk about complexity, that becomes even bigger if you're gonna handle caching...


If you really have develop a software that adapts by itself to WS interface changes, it will be very hard. But if you're forced to do so...
Nitin Tomer
Greenhorn

Joined: Feb 07, 2013
Posts: 9
Yes, you are right, i am forced to do so for the generalization sake and still no luck with this input parameters problem......
 
jQuery in Action, 2nd edition
 
subject: Help needed in calling a Web service