cxf parameter optimaization - wsdl

in cxf web service my request is
<student>
<name>jaleel</name>
<age>26</age>
</student>
here i want get age as optional
how it is possible;
i am using spring java in cxf.
my end point is
<bean id="tsetService" class="com.maxartists.tsm.server.TestServiceImpl"></bean>
<jaxws:endpoint id="issure_password_request"
address="/testserver">
<jaxws:implementor>
<bean parent="tsetService" />
</jaxws:implementor>
</jaxws:endpoint>
My web service method is
#WebService
public interface TestService {
#WebMethod
public String test( Testvo type);
#WebMethod
public Result validation(#WebParam(name="pwvalue") Studentvo ipvo);
This is my parameter type
public class Studentvo {
String name;
int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name= name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
retrun age;
}

If you change the "type" of age from "int" to Integer, it would automatically be made optional.
Alternatively, you could add an #XmlElement(required="false") attribute to the getter/setter/field and that should also make it optional.

Related

Spring Cloud Dataflow UI Not Rendering Whitelisted Properties

I have Spring Cloud DataFlow v1.3.1.RELEASE running locally, and I've created a small sample 'processor' app to illustrate what I see happening.
The Boot application has two #ConfigurationProperties classes:
DemoApplicationProperties:
#ConfigurationProperties
#Validated
public class DemoApplicationProperties {
/**
* The first name of the person.
*/
private String firstName;
/**
* The last name of the person.
*/
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
and DemoApplicationPropertiesTwo:
#ConfigurationProperties
#Validated
public class DemoApplicationPropertiesTwo {
/**
* The person's middle name.
*/
private String middleName;
/**
* The date of birth.
*/
private String birthdate;
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getBirthdate() {
return birthdate;
}
public void setBirthdate(String birthdate) {
this.birthdate = birthdate;
}
}
I also include a unit test to make sure the BootApplicationConfigurationMetadataResolver is resolving all the whitelisted classes appropriately.
public class WhiteListTests {
private BootApplicationConfigurationMetadataResolver metadataResolver;
#Test
public void testMetadataResolver() {
metadataResolver = new BootApplicationConfigurationMetadataResolver(this.getClass().getClassLoader());
Resource app = new FileSystemResource(".\\target\\classes\\");
List<ConfigurationMetadataProperty> list = metadataResolver.listProperties(app);
for(ConfigurationMetadataProperty listItem : list) {
StringBuilder sb = new StringBuilder();
sb.append(listItem.getId() + ": " + listItem.getName() + " :: " + listItem.getType());
System.out.println(sb.toString());
}
}
}
The output of the unit test is as expected:
birthdate: birthdate :: java.lang.String
middle-name: middle-name :: java.lang.String
first-name: first-name :: java.lang.String
last-name: last-name :: java.lang.String
However, when I register the Boot application as a 'processor' in Spring Cloud Dataflow, and inspect the registered application, the UI only partially renders the discovered whitelisted properties:
I have a ZIP file of the project source code, but for whatever reason, cannot figure out how to attach it here.
Inside the file spring-configuration-metadata-whitelist.properties did you add the two classes in the property ?
Example
configuration.classes = org.springframework.cloud.stream.app.file.sink.FileSinkProperties
and
com.anotherpackage.MainConfig.java
Both the properties class must be declared in the spring-configuration-metadata-whitelist.properties file. Shell, Dashboard, and REST endpoints should then be able to produce the results consistently.
Here's the same example in action.

Target state is not the requested interface org.neo4j.graphdb.Node but null

I encountered some difficulties during playing with neo4j. Firstly, when I try to delete defined #EntityModel, I get an exception (Please, forgive me the quality of pics, the exception messages are also in question title):
My Controller (this is just for testing purpouse):
#Controller
public class HomeController {
#Autowired
PersonRepository personRepository;
#RequestMapping(value="/", method = RequestMethod.GET)
public String loadPage(final Model model, final HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
Person person = new Person("My person");
personRepository.save(person);
personRepository.findOne(person.getId());
return "home";
}
}
And model:
#NodeEntity
public class Person {
#GraphId
private Long id;
private String name;
public Person() {}
public Person(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public Long getId() {
return id;
}
}
Configuration file:
#Configuration
#EnableTransactionManagement
#EnableNeo4jRepositories(basePackages = "com.springapp.mvc.repository")
#ComponentScan({"com.springapp.mvc"})
public class PersistenceConfig extends Neo4jConfiguration {
#Bean
public GraphDatabaseService graphDatabaseService() {
return new SpringRestGraphDatabase("http://localhost:7474/db/data");
}
}
My Repository:
public interface PersonRepository extends GraphRepository<Person> {
#Query("MATCH (n:Person{name: \"{namveValue}\"}) RETURN n;")
Person findByName(#Param("nameValue") final String name);
}
What am I doing wrong? I figured out that perhaps Person should implement org.neo4j.graphdb.Node and this is the source of these exceptions. However, having searched github repos I see that people do not implement this interface in their models. I have not found solution on stackoverflow so far.
Node exists in database but I cannot either delete it or save it. Please, help.
You are trying to see if a node with ID '0' exists as a person. Since the root node hasn't got a '__type__' property, the call will fail. SDN uses this property to determine the entity type of a node.
That being said, the exception seems to be caused by the following line:
if(! personRepository.exists(0L)) {

Need to look up a description for an id from database; can i use struts type converter?

I have an id in the bean and mapped in orm.xml to database. For each id I have to lookup description from database and display. If I have enum values R:"RED" G:"GREEN". Struts does type conversion using EnumConverter. I just want to do similar stuff; if id = 123 what is the product description (lookup). Can I use Struts converter by setting action.properties or by extending StrutsTypeConverter to lookup description for an id = 123? Please let me know if there are any other suggestions.
In short:- Each id I want to lookup description; where description is not part of the bean.
Product Bean
public class Product{
private Long id;
private String description;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String planDescription) {
this.description = planDescription;
}
}
Manage Bean
public class Manage{
private Long id;
private String Currency;
..and so on
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
<setters>..<getters>
}
Admin Action uses Manage Bean for all fields on UI
public class ManageAction extends ActionSupport
{
private Collection<Item> allItems;
private Manage manage;
public Collection<Item> getAllItems() {
return allItems;
}
public void setAllItems(Collection<Item> allItems) {
this.allItems = allItems;
}
}
.jsp file action = ManageAction
<s:label key="color" value="#color" />
<s:label key="id" value="%{id}" />
Here the id = 123 and I wish value gets translated to text such as "3IN - 4W - Folded" <product description>
I can have id in the bean always and look up for description each time from a cache and translate and display.
For a enum G:"GREEN" struts conveter gets us G stored in database and GREEN displayed on screen.
similarly if it find id=123 and I wish "write a converter" which looks up in the cache (may be a Map of values) and displays description.

struts2 taglib Object access in jsp

HI i have created one action, that contain one Document Object. I want to display those properties in jsp. i used to struts tag i am not able to get it , i am able to get string property of action , but not Object can you please help me... se my code below. i went all suport. i am not able to fix it. i am using tomcat7 .
public class SearchResultAction extends ActionSupport{
private static Logger log = Logger.getLogger(SearchResultAction.class);
private String name;
private DocumentData documentData;
public String execute() throws Exception {
documentData=new DocumentData();
documentData.setdocName("docName");
documentData.setdDocTitle("docTitle");
if (documentData!=null)
{
return SUCCESS;
}else{
return ERROR;
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public DocumentData getDocumentData() {
return documentData;
}
public void setDocumentData(DocumentData documentData) {
this.documentData = documentData;
}
}
My jsp code is:
<s:property value="documentData.docName" default="object is null"/>
My pojo class is:
public class DocumentData {
String docName;
String dDocTitle;
String dDocDate;
String dDocAuther;
// setters and getters for all property
}
Your docName setter doesn't follow JavaBean conventions; does your getter?
E.g., setdocName should be setDocName, the getter getDocName.
OGNL is going to call getDocName(), if the method doesn't exist, you won't get data.

How to get only parameters part from an url in struts2 use <s:url> tag?

For example, I have an URL: /test.action?a=1&b=2
Now I want in jsp page use to get only "a=1&b=2" out of the URL, how to do this?
Action Code
public class MyAction extends ActionSupport {
private String a;
private String a;
public String execute() throws Exception {
// do something here
return SUCCESS;
}
public String getA() {
return a;
}
public void setA(final String a) {
this.a= a;
}
public String getB() {
return b;
}
public void setB(final String b) {
this.a= a;
}
}
Using Struts tags:
<s:property value="a"/>
<s:property value="b"/>
Still i am not sure what exactly is your requirement as its not very clear from your question
Just a side note <s:url> This tag is used to create a URL

Resources