About Question enthuware.ocejws.v6.2.170 :

Moderators: Site Manager, fjwalraven

Post Reply
nickeasyuptech
Posts: 29
Joined: Sat Jun 08, 2013 11:33 pm
Contact:

About Question enthuware.ocejws.v6.2.170 :

Post by nickeasyuptech »

For the first correct answer, is there a proxy created?

Code: Select all

@WebServlet(urlPatterns="/math") 
public class MathTableClient extends HttpServlet {    @Addressing    
@WebServiceRef(MathTableImplService.class)    
private MathTableService service;       
 ... 
}

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

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

Post by fjwalraven »

Yes, note that this has been done when generating the client's code (deploy the WebService and use wsimport)

You might want to check the JAX-WS 2.x specifications (chapter 7.9 javax.xml.ws.WebServiceRef). You can see another example with the WebServiceRef in combination with a WebServiceFeature annotation.

Particulair for this question:
The private variable MathTableImplService is has an @WebServiceRef annotation. The MathTableImplService is the generated Service instance (not on the generated SEI). Just deploy the Webservice in the question and check what classes are generated (use wsimport)

austinor
Posts: 41
Joined: Mon Oct 27, 2014 11:35 pm
Contact:

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

Post by austinor »

Here's another that slipped through the cracks =)

Code: Select all

@WebServlet(urlPatterns="/math") 
public class MathTableClient extends HttpServlet {

    @Addressing
    @WebServiceRef( MathTableImplService.class )
    private MathTableService service;
        ... 
}
It's one of the supplied correct answers, but it will only be correct if either one of these is done:

1) the injected type above is changed to 'MathTableImpl' and in place of 'MathTableService'.

OR

2) the servlet code above stays unchanged but the SIB implementation in the question statement had:
'@WebService( endpointInterface="MathTableService" )'

Note: Don't fall for the variable name, the injected 'service' is actually a proxy type (or a portType class) that is better named as 'port' or 'proxy'. ... Very sneaky =)

austinor
Posts: 41
Joined: Mon Oct 27, 2014 11:35 pm
Contact:

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

Post by austinor »

For your reference, here's the question again:

Code: Select all

We have a Web Service that requires Addressing headers to be present in all requests. 

@Addressing(required=true) 
@WebService 
public class MathTableImpl implements MathTableService {

   @Override
    public SimpleMathTable getTable( Integer number ) {
        . . .
    } 
} 

The Web Service is used in a client. What is the correct code to enable the Addressing feature in the client?
The 1st supplied correct answer is in the previous post above. Here's the 2nd supplied correct answer:

Code: Select all

public class MathTableClient {

    public static void main( String[] args ) {

      MathTableImplService service = new MathTableImplService();
      MathTableService port = service.getMathTableImplPort( new AddressingFeature() );
      . . . 
    } 
}
Same thing applied -- either:

1) the proxy type for the variable 'port' above is changed to 'MathTableImpl' in place of 'MathTableService'.

OR

2) the client code for 'MathTableClient' above stays unchanged but the SIB implementation in the question statement should have:
'@WebService( endpointInterface="MathTableService" )'

I hope this helps. =)

austinor
Posts: 41
Joined: Mon Oct 27, 2014 11:35 pm
Contact:

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

Post by austinor »

I remember one of the questions about MTOM had an explanation like this:
If MTOM is enabled on the SERVER-side, then MTOM will also be enabled on the CLIENT-side by JAX-WS, but not the other way around.
I have a couple of questions:

1) Is this because the client 'sees' the MTOM being advertised on the wsdl of the web service? Is that the reason why it is automatically enabled on the client-side... ?

2) As to WS-Addressing, does the same reasoning also hold true? In other words, is the following statement also true?:
If WS-Addressing is enabled on the SERVER-side, then WS-Addressing will also be enabled on the CLIENT-side by JAX-WS, but not the other way around.
Thanks in advance.

austinor
Posts: 41
Joined: Mon Oct 27, 2014 11:35 pm
Contact:

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

Post by austinor »

This is answered by Question # enthuware.ocejws.v6.2.163:
How do we enable the Addressing Web Service feature on the client side?

- When the Addressing feature is active in the server, the feature is automatically switched on in the client.

- With this client code:
...
MathTableImplService service = new MathTableImplService();
MathTableService port = service.getMathTableImplPort(new AddressingFeature());
...
Explanation:

Note that if the feature is active in the server, it is also published in the WSDL. If it is published in the WSDL, the feature is enabled on the client.

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

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

Post by fjwalraven »

Here's another that slipped through the cracks =)
Same thing applied -- either: ...
I had fixed this question as well, but thanks for reminding!

I have a feeling that you answered the other questions in this thread about Addressing and MTOM. If not please reply.

Regards,
Frits

austinor
Posts: 41
Joined: Mon Oct 27, 2014 11:35 pm
Contact:

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

Post by austinor »

fjwalraven wrote:
Here's another that slipped through the cracks =)
Same thing applied -- either: ...
I had fixed this question as well, but thanks for reminding!

I have a feeling that you answered the other questions in this thread about Addressing and MTOM. If not please reply.

Regards,
Frits
Yes I answered all of them, and I think I I answered correctly for most, if not all, of them.

I was taking notes, so I tend to make connections between questions when I see them, like the similarities between MTOM and Addressing. Thanks a lot for your explanations, I'm making mental notes of them as well.

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

Yes, note that this has been done when generating the client's code (deploy the WebService and use wsimport)
How can you know for sure that MathTableService was generated with wsimport?
When used with a WebServiceRef annotation, this annotation MUST only be used when a proxy instance is created. Note that MathTableImplService is the Service instance.
How do you know that MathTableImplService is the Service instance?

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

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

Post by fjwalraven »

Hi,

If you deploy the Webservice in the problem statement you can check the WSDL and generate the client code. You will see that those are the classes generated by wsimport.

Regards,
Frits

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

Hi
If you deploy the Webservice in the problem statement you can check the WSDL and generate the client code. You will see that those are the classes generated by wsimport.
How am I suppose to know that ( know that MathTableImplService is the Service instance) on exam, without generating client code?

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

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

Post by fjwalraven »

You need to know how this works. You might want to check JSR-181 for more information.

Regards,
Frits

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

You need to know how this works.
Could you explain in brief? Another question - how do you know that classes are generated automatically by wsimport?

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

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

Post by fjwalraven »

Could you explain in brief?
Are you studying from a book? If you code a simple Webservice and publish it, you can see how the mapping is done. Furthermore (JSR-181) gives you the rules of how the mapping changes when you use attributes in the Webservice annotation.
Another question - how do you know that classes are generated automatically by wsimport?
Classes are not generated automatically: you have to generate them by using the wsimport tool.

Regards,
Frits

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

Classes are not generated automatically: you have to generate them by using the wsimport tool.
You mean that there is no way to prepare classes manually?

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

You said that classes are generated by using wsimport?
Can't they be written manually by programmer?

Another question:
@WebService  (endpointInterface="notes.ws.MathTableService") -> MathTableService is SEI here
public class MathTableImpl implements MathTableService

@WebServiceRef(MathTableImplService.class)
private MathTableService service; -> MathTableService is proxy here

MathTableService is SEI and Proxy at the same time?

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

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

Post by fjwalraven »

You said that classes are generated by using wsimport?
Can't they be written manually by programmer?
That is possible however not common.
MathTableService is SEI and Proxy at the same time?
This is what they call a SEI proxy.

From the @Addressing API:
Annotation Type Addressing
This annotation MUST only be used in conjunction with the WebService, WebServiceProvider, and WebServiceRef annotations. When used with a javax.jws.WebService annotation, this annotation MUST only be used on the service endpoint implementation class. When used with a WebServiceRef annotation, this annotation MUST only be used when a proxy instance is created. The injected SEI proxy, and endpoint MUST honor the values of the Addressing annotation.
Regards,
Frits

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

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

Post by victor2016 »

Hi,

Just to confirm, this form:

Code: Select all

@WebServiceRef(type=MathTableService.class)
As I understand, according to jaxws-2.2 specification, is incorrect because it has a missing "value" element?

But had this expression be like so:

Code: Select all

@WebServiceRef
private MathTableImplService service;
Then that would be correct?

Thanks,
Victor.

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

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

Post by fjwalraven »

Hi!
As I understand, according to jaxws-2.2 specification, is incorrect because it has a missing "value" element?
No, this is wrong because the @Addressing annotation will only work on a proxy instance (so it has nothing to do with the @WebServiceRef annotation). In other words: the type of the instance variable has to be the SEI type.
But had this expression be like so:
Code:

@WebServiceRef
private MathTableImplService service;

Then that would be correct?
When it comes to the Addressing feature there is no alternative.

Regards,
Frits

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests