You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-user@ws.apache.org by Naina S <ml...@yahoo.com> on 2003/11/03 00:59:07 UTC

Re: WSIF complexsoap dynamic client

Hello Nirmal,
Thanks a lot for your response.
Actually my problem is : I am trying to invoke the "getCountries" method similar to the sample example shown in WSIF samples. 
 
<types>                     
- <s:element name="getCountries">
  <s:complexType /> 

  </s:element>


- <s:complexType name="ArrayOfString">
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" /> 

  </s:sequence>


  </s:complexType>


- <s:element name="getCountriesResponse">
- <s:complexType>
- <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="getCountriesResult" type="s0:ArrayOfString" /> 

  </s:sequence>


  </s:complexType>
 
As  "getCountries" method return an object of "ArrayOfString" I am trying to map it.




 
                 // map types
       service.mapType(
     new QName("http://www.abundanttech.com/WebServices/Population", "ArrayOfString"),
              Class.forName(
                  "com.abundanttech.www.ArrayOfString"));
 
But still it say's it is unable to deserialize "getCountriesResponse" 
so I am mapping it
 
service.mapType(
     new QName("http://www.abundanttech.com/WebServices/Population", "getCountriesResponse"),
              Class.forName(
                  "com.abundanttech.www.GetCountriesResponse"));
 
After executing the method
    operation.executeRequestResponseOperation(input, output, fault)
 
I am getting the following errors: I am not understanding why it is unable to get the Object Part for "getCountriesResult" where as the samething works fine for your sample.
 
LatLongReturn zipInfo =
      (LatLongReturn) output.getObjectPart("GetLatLongResult");
 
 
Exception in thread "main" org.apache.wsif.WSIFException: Cannot get part 'getCo
untriesResult'. Part was not found in message
        at org.apache.wsif.base.WSIFDefaultMessage.handlePartNotFoundException(U
nknown Source)
        at org.apache.wsif.base.WSIFDefaultMessage.getObjectPart(Unknown Source)

 
I am not understanding what I am missing.
When I do the 
WSIFUtils.getWrappedDocLiteralPart(outParts ,opName+"Response");
for "getCountries" method I am not able to get the Parts which are under <types> of the wsdl.
I am wondering is there a way to display the results in raw xml format?

 
Any suggestions would be of great help to me
Thanks,
 

 

 




Nirmal Mukhi <nm...@us.ibm.com> wrote:

Hi, 

Please post your queries to wsif-user@ws.apache.org. 

It looks like you haven't mapped the complex types in your response message. The exception is pretty clear in saying that it doesn't know how to deserialize {http://www.abundanttech.com/WebServices/Population}getCountriesResponse, that is to say it doesn't know how to convert an XML element of this type to a java object. 

Nirmal. 


Naina S <ml...@yahoo.com> 
10/29/2003 09:27 PM 
        
        To:        Nirmal Mukhi/Watson/IBM@IBMUS 
        cc:        ant.elder@uk.ibm.com 
        Subject:        WSIF complexsoap dynamic client


Hello , 
As my school project I am trying to invoke webservices dynamically for which I am using your example for complexsoap dynamic client. I am using WSIF 2.0. I am using this code for invoking the Population web service.I am enclosing the wsdl doc as an attachment.I made the following changes to invoke the "getCountries" method . I am enclosing the below code as an attachment. 
  
public class CmplxSoap_population_test {
   public static void main(String[] args) throws Exception { 
        /* args[0] is the zip code
       if (args.length != 2) {
           System.out.println(
               "Usage: java complexsoap.client.dynamic.Run <wsdl location> <zip code>");
           System.exit(1);
       }
 */ 
        // create a service factory
       WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
       WSIFService service =
           factory.getService(
               args[0],
               null,
               null,
               "http://www.abundanttech.com/WebServices/Population",
               "PopulationWSSoap"); 
        // map types
       service.mapType(
     new QName("http://www.abundanttech.com/WebServices/Population", "ArrayOfString"),
              Class.forName(
                  "com.abundanttech.www.ArrayOfString"));
  
       // get the port
       WSIFPort port = service.getPort(); 
        // create the operation
  
       WSIFOperation operation = port.createOperation("getCountries"); 
        // create the input, output and fault messages associated with this operation
       WSIFMessage input = operation.createInputMessage();
       WSIFMessage output = operation.createOutputMessage();
       WSIFMessage fault = operation.createFaultMessage(); 
        // populate the input message
      // input.setObjectPart("strCountry", args[1]);
     //  input.setObjectPart("LicenseKey", ""); 
  

       // do the invocation
//try{
 //operation.executeInputOnlyOperation(input);
     if (operation.executeRequestResponseOperation(input, output, fault)) {
           // invocation succeeded, extract information from output
           // message 

           Object zipInfo =
              output.getObjectPart("getCountriesResult"); 
  
                Class cl = zipInfo.getClass();
             System.out.println(zipInfo.getClass().getName()); 
              Method[] mem = cl.getDeclaredMethods(); 
              for(int i =0; i< mem.length; i++){ 
      if(mem[i].getName().startsWith("get") && (mem[i].getParameterTypes().length) == 0)
     {
     System.out.println((mem[i].invoke(zipInfo,null)).toString()); 
      } 

    } 
 System.out.println(mem[7].getName()); 
 } 
} 
  
  
  
But I am getting the following errors: Any help will be of great help to me 
  
.wsdl
- Exception:
org.xml.sax.SAXException: Deserializing parameter 'getCountriesResponse':  could
not find deserializer for type {http://www.abundanttech.com/WebServices/Populat
ion}getCountriesResponse
       at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:276)
       at org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:893)
       at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:200)
       at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:684)
       at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:241)
       at org.apache.axis.message.RPCElement.getParams(RPCElement.java:265)
       at org.apache.axis.client.Call.invoke(Call.java:1871)
       at org.apache.axis.client.Call.invoke(Call.java:1777)
       at org.apache.axis.client.Call.invoke(Call.java:1315)
       at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.in
vokeAXISDocStyle(Unknown Source)
       at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.in
vokeRequestResponseOperation(Unknown Source)
       at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.ex
ecuteRequestResponseOperation(Unknown Source)
       at client.dynamic.CmplxSoap_population_test.main(CmplxSoap_population_te
st.java:90)
Exception in thread "main" org.apache.wsif.WSIFException: exception on AXIS invo
ke: ; nested exception is:
       org.xml.sax.SAXException: Deserializing parameter 'getCountriesResponse'
:  could not find deserializer for type {http://www.abundanttech.com/WebServices
/Population}getCountriesResponse; nested exception is:
       org.xml.sax.SAXException: Deserializing parameter 'getCountriesResponse'
:  could not find deserializer for type {http://www.abundanttech.com/WebServices
/Population}getCountriesResponse
       at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.in
vokeAXISDocStyle(Unknown Source)
       at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.in
vokeRequestResponseOperation(Unknown Source)
       at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.ex
ecuteRequestResponseOperation(Unknown Source)
       at client.dynamic.CmplxSoap_population_test.main(CmplxSoap_population_te
st.java:90)
Caused by: org.xml.sax.SAXException: Deserializing parameter 'getCountriesRespon
se':  could not find deserializer for type {http://www.abundanttech.com/WebServi
ces/Population}getCountriesResponse
       at org.apache.axis.AxisFault.makeFault(AxisFault.java:120)
       at org.apache.axis.client.Call.invoke(Call.java:1874)
       at org.apache.axis.client.Call.invoke(Call.java:1777)
       at org.apache.axis.client.Call.invoke(Call.java:1315)
       ... 4 more
Caused by: org.xml.sax.SAXException: Deserializing parameter 'getCountriesRespon
se':  could not find deserializer for type {http://www.abundanttech.com/WebServi
ces/Population}getCountriesResponse
       at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:276)
       at org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:893)
       at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:200)
       at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:684)
       at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:241)
       at org.apache.axis.message.RPCElement.getParams(RPCElement.java:265)
       at org.apache.axis.client.Call.invoke(Call.java:1871)
       ... 6 more 
  
Thanks, 
Naina 
  

---------------------------------
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://www.abundanttech.com/WebServices/Population" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www.abundanttech.com/WebServices/Population" xmlns="http://schemas.xmlsoap.org/wsdl/">
 <types>
   <s:schema elementFormDefault="qualified" targetNamespace="http://www.abundanttech.com/WebServices/Population">
     <s:element name="getWorldPopulation">
       <s:complexType />
     </s:element>
     <s:element name="getWorldPopulationResponse">
       <s:complexType>
         <s:sequence>
           <s:element minOccurs="0" maxOccurs="1" name="getWorldPopulationResult" />
         </s:sequence>
       </s:complexType>
     </s:element>
     <s:element name="getPopulation">
       <s:complexType>
         <s:sequence>
           <s:element minOccurs="0" maxOccurs="1" name="strCountry" type="s:string" />
         </s:sequence>
       </s:complexType>
     </s:element>
     <s:complexType name="Population">
       <s:sequence>
         <s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string" />
         <s:element minOccurs="0" maxOccurs="1" name="Date" type="s:string" />
         <s:element minOccurs="0" maxOccurs="1" name="Pop" type="s:string" />
       </s:sequence>
     </s:complexType>
     <s:element name="getPopulationResponse">
       <s:complexType>
         <s:sequence>
           <s:element minOccurs="0" maxOccurs="1" name="getPopulationResult" type="s0:Population" />
         </s:sequence>
       </s:complexType>
     </s:element>
     <s:element name="getCountries">
       <s:complexType />
     </s:element>
     <s:complexType name="ArrayOfString">
       <s:sequence>
         <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" />
       </s:sequence>
     </s:complexType>
     <s:element name="getCountriesResponse">
       <s:complexType>
         <s:sequence>
           <s:element minOccurs="0" maxOccurs="1" name="getCountriesResult" type="s0:ArrayOfString" />
         </s:sequence>
       </s:complexType>
     </s:element>
     <s:element name="anyType" nillable="true" />
     <s:element name="Population" nillable="true" type="s0:Population" />
     <s:element name="ArrayOfString" nillable="true" type="s0:ArrayOfString" />
   </s:schema>
 </types>
 <message name="getWorldPopulationSoapIn">
   <part name="parameters" element="s0:getWorldPopulation" />
 </message>
 <message name="getWorldPopulationSoapOut">
   <part name="parameters" element="s0:getWorldPopulationResponse" />
 </message>
 <message name="getPopulationSoapIn">
   <part name="parameters" element="s0:getPopulation" />
 </message>
 <message name="getPopulationSoapOut">
   <part name="parameters" element="s0:getPopulationResponse" />
 </message>
 <message name="getCountriesSoapIn">
   <part name="parameters" element="s0:getCountries" />
 </message>
 <message name="getCountriesSoapOut">
   <part name="parameters" element="s0:getCountriesResponse" />
 </message>
 <message name="getWorldPopulationHttpGetIn" />
 <message name="getWorldPopulationHttpGetOut">
   <part name="Body" element="s0:anyType" />
 </message>
 <message name="getPopulationHttpGetIn">
   <part name="strCountry" type="s:string" />
 </message>
 <message name="getPopulationHttpGetOut">
   <part name="Body" element="s0:Population" />
 </message>
 <message name="getCountriesHttpGetIn" />
 <message name="getCountriesHttpGetOut">
   <part name="Body" element="s0:ArrayOfString" />
 </message>
 <message name="getWorldPopulationHttpPostIn" />
 <message name="getWorldPopulationHttpPostOut">
   <part name="Body" element="s0:anyType" />
 </message>
 <message name="getPopulationHttpPostIn">
   <part name="strCountry" type="s:string" />
 </message>
 <message name="getPopulationHttpPostOut">
   <part name="Body" element="s0:Population" />
 </message>
 <message name="getCountriesHttpPostIn" />
 <message name="getCountriesHttpPostOut">
   <part name="Body" element="s0:ArrayOfString" />
 </message>
 <portType name="PopulationWSSoap">
   <operation name="getWorldPopulation">
     <input message="s0:getWorldPopulationSoapIn" />
     <output message="s0:getWorldPopulationSoapOut" />
   </operation>
   <operation name="getPopulation">
     <input message="s0:getPopulationSoapIn" />
     <output message="s0:getPopulationSoapOut" />
   </operation>
   <operation name="getCountries">
     <input message="s0:getCountriesSoapIn" />
     <output message="s0:getCountriesSoapOut" />
   </operation>
 </portType>
 <portType name="PopulationWSHttpGet">
   <operation name="getWorldPopulation">
     <input message="s0:getWorldPopulationHttpGetIn" />
     <output message="s0:getWorldPopulationHttpGetOut" />
   </operation>
   <operation name="getPopulation">
     <input message="s0:getPopulationHttpGetIn" />
     <output message="s0:getPopulationHttpGetOut" />
   </operation>
   <operation name="getCountries">
     <input message="s0:getCountriesHttpGetIn" />
     <output message="s0:getCountriesHttpGetOut" />
   </operation>
 </portType>
 <portType name="PopulationWSHttpPost">
   <operation name="getWorldPopulation">
     <input message="s0:getWorldPopulationHttpPostIn" />
     <output message="s0:getWorldPopulationHttpPostOut" />
   </operation>
   <operation name="getPopulation">
     <input message="s0:getPopulationHttpPostIn" />
     <output message="s0:getPopulationHttpPostOut" />
   </operation>
   <operation name="getCountries">
     <input message="s0:getCountriesHttpPostIn" />
     <output message="s0:getCountriesHttpPostOut" />
   </operation>
 </portType>
 <binding name="PopulationWSSoap" type="s0:PopulationWSSoap">
   <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
   <operation name="getWorldPopulation">
     <soap:operation soapAction="http://www.abundanttech.com/WebServices/Population/getWorldPopulation" style="document" />
     <input>
       <soap:body use="literal" />
     </input>
     <output>
       <soap:body use="literal" />
     </output>
   </operation>
   <operation name="getPopulation">
     <soap:operation soapAction="http://www.abundanttech.com/WebServices/Population/getPopulation" style="document" />
     <input>
       <soap:body use="literal" />
     </input>
     <output>
       <soap:body use="literal" />
     </output>
   </operation>
   <operation name="getCountries">
     <soap:operation soapAction="http://www.abundanttech.com/WebServices/Population/getCountries" style="document" />
     <input>
       <soap:body use="literal" />
     </input>
     <output>
       <soap:body use="literal" />
     </output>
   </operation>
 </binding>
 <binding name="PopulationWSHttpGet" type="s0:PopulationWSHttpGet">
   <http:binding verb="GET" />
   <operation name="getWorldPopulation">
     <http:operation location="/getWorldPopulation" />
     <input>
       <http:urlEncoded />
     </input>
     <output>
       <mime:mimeXml part="Body" />
     </output>
   </operation>
   <operation name="getPopulation">
     <http:operation location="/getPopulation" />
     <input>
       <http:urlEncoded />
     </input>
     <output>
       <mime:mimeXml part="Body" />
     </output>
   </operation>
   <operation name="getCountries">
     <http:operation location="/getCountries" />
     <input>
       <http:urlEncoded />
     </input>
     <output>
       <mime:mimeXml part="Body" />
     </output>
   </operation>
 </binding>
 <binding name="PopulationWSHttpPost" type="s0:PopulationWSHttpPost">
   <http:binding verb="POST" />
   <operation name="getWorldPopulation">
     <http:operation location="/getWorldPopulation" />
     <input>
       <mime:content type="application/x-www-form-urlencoded" />
     </input>
     <output>
       <mime:mimeXml part="Body" />
     </output>
   </operation>
   <operation name="getPopulation">
     <http:operation location="/getPopulation" />
     <input>
       <mime:content type="application/x-www-form-urlencoded" />
     </input>
     <output>
       <mime:mimeXml part="Body" />
     </output>
   </operation>
   <operation name="getCountries">
     <http:operation location="/getCountries" />
     <input>
       <mime:content type="application/x-www-form-urlencoded" />
     </input>
     <output>
       <mime:mimeXml part="Body" />
     </output>
   </operation>
 </binding>
 <service name="PopulationWS">
   <port name="PopulationWSSoap" binding="s0:PopulationWSSoap">
     <soap:address location="http://www.abundanttech.com/WebServices/Population/population.asmx" />
   </port>
   <port name="PopulationWSHttpGet" binding="s0:PopulationWSHttpGet">
     <http:address location="http://www.abundanttech.com/WebServices/Population/population.asmx" />
   </port>
   <port name="PopulationWSHttpPost" binding="s0:PopulationWSHttpPost">
     <http:address location="http://www.abundanttech.com/WebServices/Population/population.asmx" />
   </port>
 </service>
</definitions>package client.dynamic;

import javax.xml.namespace.QName;

import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.wsif.WSIFException;

import com.ibm.jrom.JROMComplexValue;

import java.lang.*;
import java.io.*;
import java.lang.reflect.Method;
import javax.xml.parsers.*;

//import complexsoap.client.stub.com.cdyne.ws.LatLongReturn;
//import stub.com.cdyne.ws.LatLongReturn;

public class CmplxSoap_population_test {
   public static void main(String[] args) throws Exception {

       /* args[0] is the zip code
       if (args.length != 2) {
           System.out.println(
               "Usage: java complexsoap.client.dynamic.Run <wsdl location> <zip code>");
           System.exit(1);
       }
                                 */

       // create a service factory
       WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
       WSIFService service =
           factory.getService(
               args[0],
               null,
               null,
               "http://www.abundanttech.com/WebServices/Population",
               "PopulationWSSoap");

       // map types


       service.mapType(
                                     new QName("http://www.abundanttech.com/WebServices/Population", "ArrayOfString"),
                                              Class.forName(
                                                  "com.abundanttech.www.ArrayOfString"));



       // get the port
       WSIFPort port = service.getPort();

       // create the operation
  //WSIFOperation operation = port.createOperation("GetLatLong", "GetLatLongHttpPostIn","GetLatLongHttpPostOut");
       WSIFOperation operation = port.createOperation("getCountries");


       // create the input, output and fault messages associated with this operation
       WSIFMessage input = operation.createInputMessage();
       WSIFMessage output = operation.createOutputMessage();
       WSIFMessage fault = operation.createFaultMessage();

       // populate the input message
      // input.setObjectPart("strCountry", args[1]);
     //  input.setObjectPart("LicenseKey", "");




       // do the invocation
     if (operation.executeRequestResponseOperation(input, output, fault))
     {

           Object zipInfo =
              output.getObjectPart("getCountriesResult");

                                                  Class cl = zipInfo.getClass();
           System.out.println(zipInfo.getClass().getName());

             Method[] mem = cl.getDeclaredMethods();

             for(int i =0; i< mem.length; i++){

                                                                     if(mem[i].getName().startsWith("get") && (mem[i].getParameterTypes().length) == 0)
                                                                     {
                                                                                     System.out.println((mem[i].invoke(zipInfo,null)).toString());

                                                                     }


                                                    }

                                                   System.out.println("invoked successfully");
       }// catch(WSIFException e) {
                                                  else{
           System.out.println("Invocation failed");
           // extract fault message info
       }
   }
}





---------------------------------
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears

UnknownExtensibilityElement

Posted by Leo Barcenas <le...@sd-net.co.jp>.
Hello!

It's me again.
I tried to debug and compared the WSDL file to the ones that
are already working. I found out that aside from the soap:address
being written as "localhost", the binding tag includes a microsoft
extension.
The exact binding code is written below:

- <binding name="MainSoapBinding" type="tns:MainSoapPort">
  <stk:binding preferredEncoding="UTF-8"
xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-extension" />
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"
/>

...

</binding>

Further, there is a UnknownExtensibilityElement in the services HashMap of
the definition
when the above mentioned is called. Is there a way that I could make the
Extensibility
known to the definition file?


Hoping for your response and help.
Any suggestion or comments are most welcome.

Many thanks.




Leo