aspose file tools*
The moose likes Web Services and the fly likes Web Service - Complex Types -  Array Inside Array. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web Service - Complex Types -  Array Inside Array." Watch "Web Service - Complex Types -  Array Inside Array." New topic
Author

Web Service - Complex Types - Array Inside Array.

Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
Hi Everybody,


I am new to web service. I need to create a web Service in which i want to add a complex type inside another complex types. Below are the details of my classes..

[b]SMSContent.java[/b]

package com.inav.ws;

public class SMSContent
{
String content = "";
String ucpa_data_coding_id = "";
String ucpa_msg_class = "";
String ucpa_msg_type = "";


public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public String getUcpa_data_coding_id() {
return ucpa_data_coding_id;
}

public void setUcpa_data_coding_id(String ucpa_data_coding_id) {
this.ucpa_data_coding_id = ucpa_data_coding_id;
}

public String getUcpa_msg_class() {
return ucpa_msg_class;
}

public void setUcpa_msg_class(String ucpa_msg_class) {
this.ucpa_msg_class = ucpa_msg_class;
}

public String getUcpa_msg_type() {
return ucpa_msg_type;
}

public void setUcpa_msg_type(String ucpa_msg_type) {
this.ucpa_msg_type = ucpa_msg_type;
}
}




[b]SMSContentArray.java[/b]


package com.inav.ws;

public class SMSContentArray
{
SMSContent[] sms_content = new SMSContent[3];

public void SMSContentArray()
{

}

public void SMSContentArray(SMSContent[] sms_content)
{
this.sms_content = sms_content;
}

public SMSContent[] getSms_content() {
return sms_content;
}

public void setSms_content(SMSContent[] sms_content) {
this.sms_content = sms_content;
}


}


MyServices.java



package com.inav.ws;

public class CPServices
{
public void smsMo(String service_id, String source_mobtel, String sub_id, String keyword, SMSContentArray sms_contents[])
{
// Processing code here
}
}



I am Using Eclipse+tomcat 5.5+Axis 1.4 to generate web service



I generated the WSDL and i am using SOAPUI to test my webservice. When i import the WSDL to SOAPUI, the Request for the smsMO() method is as below:


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.inav.com">
<soapenv:Header/>
<soapenv:Body>
<ws:smsMo>
<ws:service_id>?</ws:service_id>
<ws:source_mobtel>?</ws:source_mobtel>
<ws:sub_id>?</ws:sub_id>
<ws:keyword>?</ws:keyword>
<!--1 or more repetitions:-->
<ws:additional_info>
<ws:name>?</ws:name>
<ws:value>?</ws:value>
</ws:additional_info>
<!--1 or more repetitions:-->
<ws:sms_contents>
<ws:sms_content>
<!--Zero or more repetitions:-->
<ws:item>
<ws:content>?</ws:content>
<ws:ucpa_data_coding_id>?</ws:ucpa_data_coding_id>
<ws:ucpa_msg_class>?</ws:ucpa_msg_class>
<ws:ucpa_msg_type>?</ws:ucpa_msg_type>
</ws:item>
</ws:sms_content>
</ws:sms_contents>
</ws:smsMo>
</soapenv:Body>
</soapenv:Envelope>


But i need the SAOP Message format as below :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.inav.com">
<soapenv:Header/>
<soapenv:Body>
<ws:smsMo>
<ws:service_id>?</ws:service_id>
<ws:source_mobtel>?</ws:source_mobtel>
<ws:sub_id>?</ws:sub_id>
<ws:keyword>?</ws:keyword>
<!--1 or more repetitions:-->
<ws:additional_info>
<ws:name>?</ws:name>
<ws:value>?</ws:value>
</ws:additional_info>
<!--1 or more repetitions:-->
<ws:sms_contents>
<!--Zero or more repetitions:-->
<ws:sms_content>
<ws:content>?</ws:content>
<ws:ucpa_data_coding_id>?</ws:ucpa_data_coding_id>
<ws:ucpa_msg_class>?</ws:ucpa_msg_class>
<ws:ucpa_msg_type>?</ws:ucpa_msg_type>
</ws:sms_content>
</ws:sms_contents>
</ws:smsMo>
</soapenv:Body>
</soapenv:Envelope>


inside the <ws:sms_contents> i need an array of <ws:sms_content>

But in the generated SOAP message from the WSDL inside <ws:sms_content> one more <ws:item> is coming..

Can anyone please help me to solve this problem.. I need to complete this WSDL with in Monday.. Please help me to get out of this problem..

Thanks in advance
Nagendra E Loli
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
public void smsMo(String service_id, String source_mobtel, String sub_id, String keyword, SMSContentArray sms_contents[])


<ws:item> is there to make room for multiple copies of SMSContentArray as that is defined as array in the web service method signature.


My Blog
Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
Vinod K Singh wrote:
public void smsMo(String service_id, String source_mobtel, String sub_id, String keyword, SMSContentArray sms_contents[])


<ws:item> is there to make room for multiple copies of SMSContentArray as that is defined as array in the web service method signature.




Thanks a lot for the reply Vinod...

But can you please tell me how to retrieve the data inside <ws:item>. I dont have any implementations or any parameter or data type for the name "item".

And also my client want me to get the structure like the bleow:

<!--1 or more repetitions:-->
<ws:sms_contents>
<!--Zero or more repetitions:-->
<ws:sms_content>
<ws:content>?</ws:content>
<ws:ucpa_data_coding_id>?</ws:ucpa_data_coding_id>
<ws:ucpa_msg_class>?</ws:ucpa_msg_class>
<ws:ucpa_msg_type>?</ws:ucpa_msg_type>
</ws:sms_content>
</ws:sms_contents>

They want one <ws:sms_contents> complex type... then Inside that they want <ws:sms_content> complex type.. Inside <ws:sms_content> only my 4 parameters should reside...

But as i sent you the code, inside <ws:sms_content> one more <ws: item> is coming.. Because of this i am not able to receive any data for those 4 parameters...

Please help me to come out of this problem..
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
You need to create client side stubs to access the web service. Client side stubs should have necessary classes / methods to retrieve the objects being sent by the web service. I did not used Axis, you can have a look here to know how to create client and access the web service for JAX-WS>
Nagendra E Loli
Greenhorn

Joined: Feb 23, 2009
Posts: 12
Vinod K Singh wrote:You need to create client side stubs to access the web service. Client side stubs should have necessary classes / methods to retrieve the objects being sent by the web service. I did not used Axis, you can have a look here to know how to create client and access the web service for JAX-WS>



I am not in need of Client Vinod. One Telecommuting company is my client.. They are sending the data for me.. For that i have to create the service like the format which i sent to you before..

If the 4 parameters wont come inside the <ws: sms_content> means i cant receive any data.. and i need the <ws: sms_content> array.. but i am not getting that array now.. Array is coming for <ws: item>

If you give your mail ID i can contact you directly.. My mail ID is nagendra.ge@gmail.com..

Please help me Vinod.. I need solution for this in urgent...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Service - Complex Types - Array Inside Array.