Hi Balaji,
I tried it using tcpmon but nothing come in tcpmon and in the eclipse console the error i got given below.......
please help me.........
i have sented all my code. but i dont know where is wrong ... so please help me
//services.xml file
<service name="service" scope="application">
<description>Weather POJO Service</description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
<parameter name="ServiceClass">edujinilabs.Service</parameter>
</service>
//service.java file
package edujinilabs;
import com.edujinilabs.aksh.quiz.Quiz;
public class Service
{
Quiz quiz;
public void submitQuiz(Quiz quiz)
{
this.quiz=quiz;
}
public Quiz getQuiz()
{
return quiz;
}
}
//client file
package client;
import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import com.edujinilabs.aksh.quiz.Quiz;
public class QuizClient
{
public static void main(
String[] args) throws AxisFault
{
RPCServiceClient client = new RPCServiceClient();
Options op = client.getOptions();
EndpointReference epr = new EndpointReference("http://localhost:8888/axis2/services/service");
op.setTo(epr);
// for Quiz
QName opSetQuiz = new QName("http://quiz.aksh.edujinilabs.com/xsd", "submitQuiz");
Quiz q=new Quiz();
q.setDescription("QuizDesc");
q.setTitle("QuizTitle");
q.setQuizId("QuizID");
Object[] opSetQuizArgs = new Object[] {q};
client.invokeRobust(opSetQuiz, opSetQuizArgs);
// Getting MyQuiz Parameter
QName GetInsert1 = new QName("http://quiz.aksh.edujinilabs.com/xsd", "getQuiz");
Object[] opGetQuizArg1 = new Object[] {};
Class[] returnTypes1 = new Class[] {Quiz.class};
Object[] response1 = client.invokeBlocking(GetInsert1, opGetQuizArg1, returnTypes1);
Quiz quiz=(Quiz)response1[0];
if(quiz == null)
{
System.out.println("Time didnot initialize!");
return;
}
System.out.println("Title :" + quiz.getTitle());
System.out.println("Description :" + quiz.getDescription());
System.out.println("getQuiz methoid end......."+quiz.getQuizId());
}
}
and the Quiz.java file is
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONException;
import org.json.JSONObject;
@JSONObjectAnnotation(name = "aksh.quiz.Quiz")
@JSONCustomSerializationMethod("customInfo")
public class Quiz
{
@JSONObjectAnnotation(order = 0)
private String quizID;
@JSONObjectAnnotation
private String title;
@JSONObjectAnnotation
private String description;
//*
@JSONObjectAnnotation
@JSONDataTypeAnnotation(JSONDataType.Date)
private Date startDate;
@JSONObjectAnnotation
@JSONDataTypeAnnotation(JSONDataType.Date)
private Date endDate;
@JSONObjectAnnotation
private Timespan duration;
@JSONObjectAnnotation
private int sectionCount;
@JSONObjectAnnotation
private int questionCount;
@JSONObjectAnnotation
@JSONDataTypeAnnotation(JSONDataType.Date)
private Date serverTime;
private HashMap<String, Object> extraInfo = new HashMap<String, Object>();
private HashMap<String, Object> userData = new HashMap<String, Object>();
@JSONObjectAnnotation
@JSONDataTypeAnnotation(JSONDataType.Array)
private QuizSectionList sections = new QuizSectionList();
@JSONObjectAnnotation
@JSONDataTypeAnnotation(JSONDataType.Array)
private QuizQuestionList questions = new QuizQuestionList();
//*/
public String getQuizId()
{
return quizID;
}
public void setQuizId(String quizID)
{
this.quizID = quizID;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
//*
public Date getStartDate()
{
return startDate;
}
public void setStartDate(Date startDate)
{
this.startDate = startDate;
}
public Date getEndDate()
{
return endDate;
}
public void setEndDate(Date endDate)
{
this.endDate = endDate;
}
public Timespan getDurartion()
{
return duration;
}
public void setDuration(Timespan duration)
{
this.duration = duration;
}
public int getSectionCount()
{
return sectionCount;
}
public void setSectionCount(int sectionCount)
{
this.sectionCount = sectionCount;
}
public void incrementSectionCount()
{
sectionCount++;
}
public int getQuestionCount()
{
return questionCount;
}
public void setQuestionCount(int questionCount)
{
this.questionCount = questionCount;
}
public void incrementQuestionCount()
{
questionCount++;
}
public Date getServerTime()
{
return serverTime;
}
public void setServerTime(Date serverTime)
{
this.serverTime = serverTime;
}
public void setExtraInfo(HashMap<String, Object> extraInfo)
{
this.extraInfo = extraInfo;
}
public HashMap<String, Object> getExtraInfo()
{
return extraInfo;
}
public void setUserData(HashMap<String, Object> userData)
{
this.userData = userData;
}
public HashMap<String, Object> getUserData()
{
return userData;
}
public QuizQuestionList getQuestions()
{
return questions;
}
public void setQuestions(QuizQuestionList questions)
{
this.questions = questions;
}
public QuizSectionList getSections()
{
return sections;
}
public void setSections(QuizSectionList sections)
{
this.sections = sections;
}
public void customInfo(JSONObject obj, boolean isSerializing)
{
if(isSerializing)
{
JSONObject extraInfo = new JSONObject();
JSONObject userDataObj = new JSONObject();
try
{
boolean hasExtraInfo = setValuesToJSONObject(this.extraInfo, extraInfo);
if(hasExtraInfo)
{
obj.put("extraInfo", extraInfo);
}
boolean hasUserData = setValuesToJSONObject(this.userData, userDataObj);
if(hasUserData)
{
obj.put("userData", userDataObj);
}
} catch (JSONException je)
{
je.printStackTrace();
}
} else
{
JSONObject extraInfoObj = obj.optJSONObject("extraInfo");
if(extraInfoObj != null)
{
setValuesToHashmap(extraInfoObj, this.extraInfo);
}
JSONObject userData = obj.optJSONObject("userData");
UserData ud = null;
if(userData != null)
{
try
{
userData.putOpt("_type", UserData.class.getName());
ud = (UserData) JSONDeserializer.deserialize(userData.toString());
this.userData.put("userInfo", ud);
} catch (JSONException e)
{
e.printStackTrace();
}
}
}
}
//*/
public boolean setValuesToJSONObject(HashMap<String, Object> hashMap,
JSONObject jsonObject)
{
boolean setValues = false;
try
{
for(String key : hashMap.keySet())
{
if(!jsonObject.has(key))
{
setValues = true;
Object value = JSONCodec.encode(hashMap.get(key));
jsonObject.put(key, value);
}
}
} catch (JSONException e)
{
e.printStackTrace();
}
return setValues;
}
public boolean setValuesToHashmap(JSONObject jsonObject, HashMap<String, Object> hashMap)
{
boolean setValues = false;
Iterator udKeys = jsonObject.keys();
while(udKeys.hasNext())
{
String key = (String) udKeys.next();
Object value = JSONCodec.decode(jsonObject.opt(key));
if(value != null && value.toString().length() != 0)
{
setValues = true;
hashMap.put(key, value);
} else
{
hashMap.put(key, null);
}
}
return setValues;
}
}
///Exception after executing
Exception in
thread "main" org.apache.axiom.om.OMException: java.lang.NullPointerException
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:211)
at org.apache.axiom.om.impl.llom.OMNodeImpl.build(OMNodeImpl.java:315)
at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:608)
at org.apache.axiom.om.impl.llom.OMElementImpl.detach(OMElementImpl.java:577)
at org.apache.axiom.om.impl.llom.OMNodeImpl.setParent(OMNodeImpl.java:114)
at org.apache.axiom.om.impl.llom.OMElementImpl.addChild(OMElementImpl.java:236)
at org.apache.axiom.om.impl.llom.OMElementImpl.addChild(OMElementImpl.java:192)
at org.apache.axis2.client.ServiceClient.fillSOAPEnvelope(ServiceClient.java:631)
at org.apache.axis2.client.ServiceClient.sendRobust(ServiceClient.java:443)
at org.apache.axis2.client.ServiceClient.sendRobust(ServiceClient.java:426)
at org.apache.axis2.rpc.client.RPCServiceClient.invokeRobust(RPCServiceClient.java:132)
at client.QuizClient.main(QuizClient.java:29)
Caused by: java.lang.NullPointerException
at org.apache.axis2.databinding.utils.BeanUtil.getPullParser(BeanUtil.java:272)
at org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl.processProperties(ADBXMLStreamReaderImpl.java:926)
at org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl.next(ADBXMLStreamReaderImpl.java:780)
at org.apache.axis2.util.StreamWrapper.next(StreamWrapper.java:68)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:125)
... 11 more