[prev in list] [next in list] [prev in thread] [next in thread] 

List:       axis-user
Subject:    Re: Axis2 and wsdl- Exception thrown when client attempting
From:       svaens <sean () astraia ! com>
Date:       2008-04-29 11:53:23
Message-ID: 16958782.post () talk ! nabble ! com
[Download RAW message or body]


Hi, thanks again for your replies!

I actually have it working now. HOWEVER!!! (isn't there always a catch!).
I still don't know what was the cause of the problem. 
I will explain how I got the client / server process to work. But first, let
me start from the start:

once upon a time.... 

I received a wsdl file from someone, and my task is to test it by creating a
server, and a client which can communicate. This is what I've been trying to
do. Call a wsdl function on the server, returning an serialized object to
the client as the response.  

So I took the wsdl file, and generated files for the server using
wsdl2java.sh , which came with the axis2.1_3 distribution.  I also generated
the Stub java file for the client using this tool and the source wsdl file. 

This is where I had my problem. The client could not successfully
communicate to the server. 

To get around this problem, I tried retrieving a NEWLY GENERATED WSDL file
from using the browser to contact the server and retrieve a wsdl file
generated from the generated Java files, which were in turn originally
generated from my source wsdl file. 

ALARM!!! The original wsdl file, and the newly generated wsdl files are NOT
the same!!! 
they differ in several ways. 

1. the targetNamespace attribute listed in the wsdl:definitions tag shows
the namespace backwards!!
2. The new generated wsdl file has two extra element types, 
    GetPersonInfo, and GetPersonInfoResponse,  + GetPersonInfoIn ,
GetPersonInfoOut
while the original only game me GetPersonInfoOut & GetPersonInfoIn.

Never mind for now, I thought, I'll continue with this test, and see if it
works anyway. 

So I did, and so, with the introduction of these two extra types I had to
slightly modify my code, but, 
it worked!!!

What is going on here!!


Here is the new code, and how I had to adapt it to the different Stub file
generated from the changed wsdl:



        try
        {	
            ConfigurationContext context = ConfigurationContextFactory.
            createDefaultConfigurationContext();	
        	
        	PersonInfoStub stub =
                new PersonInfoStub(context);

            GetPersonInfo reqs =
                new GetPersonInfo();
            
			//GetPersonInfoIn req = reqs.getGetPersonInfoIn();
            
			GetPersonInfoIn req = new GetPersonInfoIn();
			reqs.setGetPersonInfoIn(req);
			
            req.setCivilRegistrationIdentifier("CIV123");
            req.setHospitalCode("HOS123");
            req.setRequestId("123");
            req.setUserName("sean");
            
            GetPersonInfoResponse res = stub.getPersonInfo(reqs);
            
            GetPersonInfoOut resultObj = res.get_return();
            

			OMFactory fac = OMAbstractFactory.getOMFactory();
			OMElement xml = resultObj.getOMElement(GetPersonInfoResponse.MY_QNAME,
fac);
			
			//XMLOutputFactory xof = XMLOutputFactory.newInstance();		
			XMLStreamWriter writer =
				XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
			
			writeOMElement(xml, writer);
            
            
            
            
        //    System.out.println(res.getSuccessfulAdd());
        //    System.out.println(res.getItemId());
        } catch(Exception e){
            e.printStackTrace();
            System.out.println("\n\n\n");
        }










Upul Godage wrote:
> 
> Actually when you write and pass nulls,
> ConfigurationContext context =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
> null);
> I think it uses a default bundled axi2.xml. So anyway an axis2.xml is
> used.
> 
> When context path is not the one given in axis2.xml, axis2server redirects
> it to the context path. So the client may not be handling the redirect
> responses and returning error for code 301. But the browser is anyway
> supporting that.
> 
> Upul
> 
> 

-- 
View this message in context: \
http://www.nabble.com/Axis2-and-wsdl--Exception-thrown-when-client-attempting-connection-to-SimpleHTTPServer-tp16934147p16958782.html
 Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic