• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Don't understand service.addPort

 
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Himai Minh
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you trying to prove? What is your objective?
 
Himai Minh
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This topic was also discussed in this thread.
 
reply
    Bookmark Topic Watch Topic
  • New Topic