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

@webparam

sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 124
Hi
I have one requirement, in my SOAP i have to use fields which has - (hiphens) , which cannot be used in Java objects as field names .
For example <ValidatePinRequest>
<user-pin></user-pin>
<user-id></user-id>
</ValidatePinRequest>

And in my Java Object i have a class ValidatePinRequest ,and it has fields userPin, userId ( i cannot name it user-pin,user-id).
Is there anyway we can use webparam annotation to map it ?

thanks in advance.
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1086
    
    1

Here you go



Service is published at http://localhost:8085/ValidatePin

Now I used SOAP UI tool to test the code. Configured service in SOAP UI and generated Request XML.

Request XML in SOAP UI



Response got in SOAP UI




Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 124
thanks a lot abhay ,but one query what about if my fields are all in a POJO.
But wheenver i annote it, it says invalid location of webparam

for example

public class User{

@WebParam(
@WebParam(name = "user-id") String userId;

//getter setter

any idea on this?
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1086
    
    1

Correct. @Webparam can not be applied at the location where you are trying to apply it.
For these kind of requirements, you may have to write your own client and server side code using Low level API (for example using Provider, Dispatch and SOAP Message classes)
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1086
    
    1

Hello

Finally found simple solution to your problem. It just striked me few minutes back. Just remember that XML generation is backed by JAXB.
I have used JAXB annotations to solve your problem

Below mentioned is the code.



SOAP Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pin="http://pin.validation.com/">
<soapenv:Header/>
<soapenv:Body>
<pin:ValidatePinRequest>
<!--Optional:-->
<user-id>abhay</user-id>
<!--Optional:-->
<user-pin>pin001</user-pin>
</pin:ValidatePinRequest>
</soapenv:Body>
</soapenv:Envelope>


SOAP Response

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:ValidatePinRequestResponse xmlns:ns2="http://pin.validation.com/">true</ns2:ValidatePinRequestResponse>
</S:Body>
</S:Envelope>


sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 124
Hi abhay I tried your suggestion and am using ant task jws even though no errors while building but when I check the wsdl after generations the fields are still the same
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1086
    
    1

Ok. I ran my code through eclipse. not used Ant task.
Please provide your Ant task code here. I will try to execute on my machine.

~ abhay



Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1086
    
    1

also please post WSDL file and XSD file which got generated from Ant task
sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 124
Hi Abhay
Unfortunately I cannot copy the wsdl and saop here.
Any idea if jaxb is compatible with weblogic 9.2 or not? am using weblogic 9.2 and jaxb 2.1...everything executes fine but at the end wsdl has no change its generating exactly as it field names are.

Regards
Sudharsan
sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 124
by the way which version of weblogic are you using?
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1086
    
    1

hi

I did not used Weblogic to run my sample code (shown in previous post).
I use Java 7 integrated JAX-WS and SOAPUI to execute my piece of code.
Your problem seem like to more specific.
I try to find any solution to it. But it is difficult as it seem that reason for error may drill down to some specific settings in weblogic or jaxb .

thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @webparam