aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Don't understand service.addPort Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Don Watch "Don New topic
Author

Don't understand service.addPort

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
Hi, I don't understand what service.addport does.
Suppose we have this code :


To my understanding from the API, addPort means to add a port name that does not exist in the WSDL. But how about endpointAddress? What is it supposed to be? Should it be any new endpoint address or any existing address?
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
Himai Minh wrote:
To my understanding from the API, addPort means to add a port name that does not exist in the WSDL.

That's not correct. You can't just add a port from the blue. Adding a port corresponds to what the service tag of the WSDL does. When a Service instance is created with a WSDL URL, it'll try to access the WSDL. Whatever you do later, is compared against that WSDL.
Have you looked at the Javadoc? Service#addPort
Himai Minh wrote:
But how about endpointAddress? What is it supposed to be? Should it be any new endpoint address or any existing address?

If you put any address to which a service hasn't been published, what do you think will happen? Who is listening on that port to receive your request and process it?

Abhijit
-------
SCJP 5, SCBCD 5, OCWCD 5, OCEWSD 6, CSM
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
I tried to use Ivan's StringProcessor as an example,
https://gist.github.com/HimaiMinh/7725001

On the client side, I add a new port called StringProcessor1 , which is not in the WSDL. But I ran into an error message saying the JAXBElement cannot be marshalled. It expects to have a SOAP envelope.
But the service mode is PAYLOAD, not MESSAGE.
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
What are you trying to prove? What is your objective?
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
I was trying to use addport method to add a new port , and use this new port to invoke the web service. But I can't do that and end up with the error. Don't know why.
a sarkar
Ranch Hand

Joined: Aug 05, 2010
Posts: 92
Himai Minh wrote:I was trying to use addport method to add a new port , and use this new port to invoke the web service. But I can't do that and end up with the error. Don't know why.

I think you're getting the error because you're supposed to. If we look at the WSDL structure, the service just provides one or more actual network address(es) to a binding. The binding, in turn, configures some properties on the portType. The portType is an abstract collection of operations. So essentially, the service is just telling you where to find a concrete implementation of the portType using the port child element.
With that understanding, if you try to add a Port that doesn't correspond to any portType, it doesn't make sense and it'll never work. You can't change the behavior or implementation of the service from the client side.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
But according to this site : http://fusesource.com/docs/esb/4.2/jaxws/JAXWSConsumerDevJavaFirstPort.html
The addPort method means:
"The Service class defines an addPort() method, shown in Example 2.3, that is used in cases where there is no WSDL contract available to the consumer implementation. The addPort() method allows you to give a Service object the information, which is typically stored in a wsdl:port element, necessary to create a proxy for a service implementation"
The service is created with the URL of the WSDL.
When there is no WSDL contract available, how can the client connect to the service?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

This topic was also discussed in this thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Don't understand service.addPort