• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

general web service definition question

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have the following class

@XmlAccessorType(XmlAccessType.FIELD)
public class Payment {

@XmlElement(required = true)
private String paymentID;

@XmlElement(required = false, nillable = true)
protected List<PaymentStatusHistoryDetail> statusHistory;
}


my questions are:

1. how can i limit the string lenght for paymentID
2. how can i limit the list lengh for statusHistory, ie, i want only 4 items.
3. is there way to use an annotation as validator for paymentID.

thank you for help
 
Ranch Hand
Posts: 30
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even if a restiction like the below is put inline with the element in wsdl , the generated classes do not have any annotation to restrict the length.
I usually code a handler to intercept the request and validate against the schema.

You can try to add the maxlength attribute in wsdl to see if that helps the lists size.
As I said before it may not reflect in the annotations. You could do this validation too in the handler.

<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but if i use .xsd to define all the datatype it could be too difficult to maintain since i have 2 places need to work on java code and .xsd file.

i am really hoping there is way to annotate the attributes so that i could do validation once data is entered.

 
Lingan Rajan
Ranch Hand
Posts: 30
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim
I may be missing something here , But usually you should be able to refer the XSD from within your WSDL and generate the classes.
This way it is always only one place where you are maintining the definitions.
 
Ranch Hand
Posts: 2198
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

jim li wrote:i am really hoping there is way to annotate the attributes so that i could do validation once data is entered.


As far as I know, JAXB has no support for this.
You may be able to use JSR 303, aka Bean Validation, to annotate the JAXB classes.
However, I feel that the solution suggested by Lingan Rajan in connection with WSDL-first development is a much better idea.
Best wishes!
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lingan Rajan wrote:Jim
I may be missing something here , But usually you should be able to refer the XSD from within your WSDL and generate the classes.
This way it is always only one place where you are maintining the definitions.



1 .so for the datatype definition, do i have to manually define them or can i use to tool to generate it .

2. once have the datatype definition ready in .xsd, and i generate wsld file and .xsd file from my java classes.

how can i associate datatype .xsd file with .xsd files which are generated from java. do i have to manually change it ? (i mean change it line by line since the .xsd from java class has its original definition instead of pointing to datatype which i defined.)

thank you
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
If you want to do code-first development, you can do this the first time and let JAX-WS generated the WSDL and XML schemas for you.
However, after the first time, you use the WSDL-first approach and only change the WSDL and/or XML schemas, from which you then generate artifacts.
So:
1. JAX-WS can generate them for you the first time.
2. You generate artifacts from the WSDL which, if needed, imports any XML schemas it uses.

To make sure that your JAX-WS web service uses the existing WSDL and does not generate a new one, use the wsdlLocation attribute in the @WebService annotation.
Best wishes!
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:Hi!
If you want to do code-first development, you can do this the first time and let JAX-WS generated the WSDL and XML schemas for you.
However, after the first time, you use the WSDL-first approach and only change the WSDL and/or XML schemas, from which you then generate artifacts.
So:
1. JAX-WS can generate them for you the first time.
2. You generate artifacts from the WSDL which, if needed, imports any XML schemas it uses.

To make sure that your JAX-WS web service uses the existing WSDL and does not generate a new one, use the wsdlLocation attribute in the @WebService annotation.
Best wishes!



this is what i did:

1. generate wsdl and .xsd files
2. import defined data type <xs:include schemaLocation="WebServiceDataType.xsd"/>
manually edit the .xsd file such as change the variable type from String to customizedString which is defined in a separate .xsd file

3. generate java code based on the wsld file and .xsd files
4. generate wsld and .xsd file based on the java classes. (now here is the problem, the variable that i defined as customizedString in .xsd files has changed back to String, can anyone tell me how to not make this happen, i want my customized data type. in addition, my include line
<xs:include schemaLocation="WebServiceDataType.xsd"/> is gone
)

please help

thank you
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Have you, as I suggested in my earlier post, modified in the @WebService annotation to point to the existing WSDL, using the wsdlLocation attribute?
Best wishes!
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:Hi!
Have you, as I suggested in my earlier post, modified in the @WebService annotation to point to the existing WSDL, using the wsdlLocation attribute?
Best wishes!




Hi Ivan

thank you for the reply. i still got problems.

1. i have one aaservice. wsdl file, one aaservice_chemea.xsd file , and one datatype xsd file which was created by me mannually (datatype .xsd file is included in aaservice_chemea.xsd)
2. generate java classes based on aaservice. wsdl file.
3. generate wsdl files based on java classes with wsdlLocation which points to the existing wsdl file
4. aaservice. wsdl file, aaservice_chemea.xsd file are overridden. datatype .xsd file is not included in aaservice_chemea.xsd. (this is the problem, since i do not want to go through every atrribute again and manually edit them to point to a datatype which is defined in .xsd file again)

how can i fix it?
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Why do you do step 3? Have you tried skipping it?
It seems unnecessary to me - just modify the generated classes to point to the existing WSDL.
Best wishes!
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:Hi!
Have you, as I suggested in my earlier post, modified in the @WebService annotation to point to the existing WSDL, using the wsdlLocation attribute?
Best wishes!



Hi Ivan,

I am trying to re-use my existing wsdl for a JAX-WS application I created. (I am using Glassfishv3 with RI version - JAX-WS RI 2.2-hudson-752).

I placed my wsdl in the WEB-INF/wsdl folder. the value of @WebService.wsdlLocation is the name of my wsdl file . However every time I access the wsdl a generated file is being dispensed.
When I referred the glassfish RI 2.2 annotation documents it says that this feature is currently not implemented. I was wondering which version of RI or server were you using. Or if I am doing something wrong please let me know. Thanks.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I have succeeded specifying the location of an existing WSDL like this:

Note how the location of the WSDL is specified using the wsdlLocation attribute.
Best wishes!
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic