About Question enthuware.ocejws.v6.2.123 :

Moderators: Site Manager, fjwalraven

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

About Question enthuware.ocejws.v6.2.123 :

Post by himaiMinh » Mon Apr 07, 2014 1:01 pm

If the client expects the response as a SOAPMessage, the response will be empty since the web method is void.
For example, the client is a dispatch client like this:

Code: Select all

SOAPMessage response = dispatch.invoke(request); //where the request is a SOAP request 

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by fjwalraven » Mon Apr 07, 2014 1:39 pm

Hi Himai,

I am not sure what you are trying to say, but in order to use an input/output parameter your web method has to declare void as a result (as shown in the example in the explanation)

Regards,
Frits

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by himaiMinh » Mon Apr 07, 2014 2:06 pm

Hi,
public void add(int num, Holder<Integer> n, Holder<Integer> m){ ...}
The request may be:
<soap:body>
<a:add xmlns:a="....">
<num>...
<n> ....
<m> .....
</a:add>
</soap:body>

The response may be:
<soap:body>
<a:addResponse/>
</soap:body>
Since add is a void method, the response is always empty according to the WSDL and schema.
So, if the dispatch client receives the response as a SOAPMessage, the client won't see any output.

I agree the proxy client will get updates in the parameter m and n.

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by fjwalraven » Mon Apr 07, 2014 2:32 pm

Since add is a void method, the response is always empty according to the WSDL and schema. So, if the dispatch client receives the response as a SOAPMessage, the client won't see any output.
With Holder<T> types this works a bit different. In fact the types show up in the types section of the WSDL.

Code: Select all

<xs:schema xmlns:tns="http://ws.notes.nl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://ws.notes.nl/">
<xs:element name="getMathResult" type="tns:getMathResult"/>
<xs:element name="getMathResultResponse" type="tns:getMathResultResponse"/>
<xs:complexType name="getMathResult">
 <xs:sequence>
  <xs:element name="arg0" type="xs:int"/>
  <xs:element name="arg1" type="xs:int" minOccurs="0"/>
  <xs:element name="arg2" type="xs:int" minOccurs="0"/>
 </xs:sequence>
</xs:complexType>
<xs:complexType name="getMathResultResponse">
 <xs:sequence>
  <xs:element name="arg1" type="xs:int" minOccurs="0"/>
  <xs:element name="arg2" type="xs:int" minOccurs="0"/>
 </xs:sequence>
</xs:complexType>
</xs:schema>
So the SOAP message request will have 3 parameters and the SOAP message response 2 parameters.

Regards,
Frits

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by himaiMinh » Tue Apr 08, 2014 7:35 pm

I published the MathServiceImp using NetBean.
I found something interesting:

Code: Select all

//Schema from the WDSL
<xs:schema version="1.0" targetNamespace="http://InOutEx/">
<xs:element name="getMathResult" type="tns:getMathResult"/>
<xs:element name="getMathResultResponse" type="tns:getMathResultResponse"/><xs:complexType name="getMathResult">
<xs:sequence>
       <xs:element name="arg0" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getMathResultResponse">
<xs:sequence>
        <xs:element name="arg1" type="xs:int" minOccurs="0"/>
        <xs:element name="arg2" type="xs:int" minOccurs="0"/>
       <xs:element name="arg3" type="xs:int" minOccurs="0"/>
 </xs:sequence>
</xs:complexType>
</xs:schema>
From this WSDL, the request should only have 1 parameter, arg0. But the proxy client expect to have all 4 parameters.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by himaiMinh » Tue Apr 08, 2014 7:47 pm

Another interesting finding:
If the WebParam mode is INOUT in the SIB, the WSDL is:

Code: Select all

<xs:schema version="1.0" targetNamespace="http://InOutEx/">
<xs:element name="getMathResult" type="tns:getMathResult"/>
<xs:element name="getMathResultResponse" type="tns:getMathResultResponse"/><xs:complexType name="getMathResult">
     <xs:sequence>
     <xs:element name="arg0" type="xs:int"/>
    <xs:element name="arg1" type="xs:int" minOccurs="0"/>
    <xs:element name="arg2" type="xs:int" minOccurs="0"/>
    <xs:element name="arg3" type="xs:int" minOccurs="0"/>
   </xs:sequence>
</xs:complexType>
<xs:complexType name="getMathResultResponse">
   <xs:sequence>
       <xs:element name="arg1" type="xs:int" minOccurs="0"/>
       <xs:element name="arg2" type="xs:int" minOccurs="0"/>
       <xs:element name="arg3" type="xs:int" minOccurs="0"/>
     </xs:sequence>
</xs:complexType>
</xs:schema>
The proxy client is the same, taking 4 parameters.

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by fjwalraven » Tue Apr 08, 2014 10:51 pm

Hi Himai,

This thread is about question 2.123
The proxy client is the same, taking 4 parameters.
Can you please stick to the number of parameters (3) otherwise other people reading this thread might get confused.

Thanks,
Frits

rkbansal83
Posts: 33
Joined: Sat Nov 24, 2012 8:52 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by rkbansal83 » Mon Apr 14, 2014 11:47 am

Frits ,

Expalaination of this question has below sample client
is this client correct ? in all the explainations I read so far , is that get Port method cant be without parameters . How come getMathServiceImplPort() is getting invoked then ?

To invoke the Web Service:

Code: Select all

public class MathServiceClient {  
 public static void main(String[] args) {    
MathServiceImplService service = new MathServiceImplService();    
MathService endpoint = service.getMathServiceImplPort();
// initialize Holder objects    final Holder<Integer> m = new Holder<Integer>(null);    
final Holder<Integer> n = new Holder<Integer>(null);   
 final Holder<Integer> o = new Holder<Integer>(null);    
final int inputNumber=4;     endpoint.getMathResult(inputNumber,m,n,o);    
 System.out.println("maths for number: " + inputNumber);    
System.out.println("square: " + m.value);    
System.out.println("volume: " + n.value);   
 System.out.println("factorial: " + o.value);   } }

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by fjwalraven » Mon Apr 14, 2014 2:53 pm

Expalaination of this question has below sample client
is this client correct ? i
Yes, it is an example that works. Just try it yourself and read something about the Holder parameter and its use.
in all the explainations I read so far , is that get Port method cant be without parameters . How come getMathServiceImplPort() is getting invoked then ?
With four parameters:

Code: Select all

endpoint.getMathResult(inputNumber,m,n,o);   
Regards,
Frits

rkbansal83
Posts: 33
Joined: Sat Nov 24, 2012 8:52 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by rkbansal83 » Mon Apr 14, 2014 10:25 pm

Thanks Frits .

But I am talking about this line of code in the client.

Code: Select all

MathService endpoint = service.getMathServiceImplPort();
in this line of code , getMathServiceImplPort is being invoked without any parameter. is this the correct way of calling get port function ? I read in few other answers that it can't be without params .

Shouldn't it be something like

Code: Select all

MathService endpoint = service.getMathServiceImplPort(MathService .class);

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by himaiMinh » Tue Apr 15, 2014 8:56 am

In javax.xml.ws.Service's API, I don't see any getXXXPort methods.
But in your generated class annotated with @WebServiceClient, there is a@WebEndpoint method, getXXXPort() method and a getXXXPort(WebServiceFeature ... feature) method.

I have this:

Code: Select all

//Only relevant part shown
@WebServiceClient(name = "MathServiceImplService"....)
public class MathServiceImplService extends Service
{
   @WebEndpoint(name = "MathServiceImplPort")
    public MathService getMathServiceImplPort() {
      ....
     }
   @WebEndpoint(name = "MathServiceImplPort")
    public MathService getMathServiceImplPort(WebServiceFeature... features) {
     ...
    }
}

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by fjwalraven » Tue Apr 15, 2014 9:45 am

Then you are both using an old version of JAX-WS.

Check the generated client source and verify the version
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.1.6 in JDK 6
* Generated source version: 2.1
*
*/
Als verify the version of wsimport
wsimport -version
JAX-WS RI 2.1.6 in JDK 6
Regards,
Frits

victor2016
Posts: 12
Joined: Wed Jan 20, 2016 7:16 pm
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by victor2016 » Sun Sep 25, 2016 12:04 pm

Hi,

As I understand declarative security is done using deployment descriptor (i.e. web.xml). But it is impossible to define a role in web.xml that allows/denies access to a method. So could the answer be also that it cannot be done using declarative security?

Thanks,
Victor.

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.123 :

Post by fjwalraven » Mon Sep 26, 2016 4:12 am

Hi Victor!

You can use Declarative Security and Programmatic Security.

Declarative Security can be done by using deployment descriptors and/or annotations.

Programmatic Security is only useful when the standard EE-security framework does not fulfil all your security constraints.

Check:
http://docs.oracle.com/javaee/5/tutorial/doc/bnbxe.html

Regards,
Frits

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests