Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

binding and service elements in wsdl

 
Femi Byte
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about this fragment in the WSDL spec:

<portType name="StockQuotePortType">
<operation name="GetLastTradePrice" parameterOrder="tickerSymbol timePeriod frequency">
<input message="tns:GetTradePricesInput"/>
<output message="tns:GetTradePricesOutput"/>
</operation>
</portType>
<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetTradePrices">
<soap peration soapAction="http://example.com/GetTradePrices"/>
<input>
<soap:body use="encoded" namespace="http://example.com/stockquote"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://example.com/stockquote"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>>
</binding>

<service name="StockQuoteService">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding">
<soap:address location="http://example.com/stockquote"/>
</port>
</service>
</definitions>

The port sub-element in the service element above specifies its name attribute as StockQuotePort and its binding attribute as StockQuoteBinding.
Is this correct? I would have thought that the name attribute would corr. to the portType name above, i.e. StockQuotePortType and the binding attribute to the binding element name attribute i.e. StockQuoteSoapBinding. Otherwise, how do we know what StockQuotePort and StockQuoteBinding refer to? Any clarification on this would be greatly appreciated.
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Femi,
Good question. The WSDL snippet you posted is not correct as it is not pointing to correct binding.
Coming to port definition inside service element.. name attribute can be any unique and it need not refer to portType element name. But binding attribute should be pointing to the name of binding element.
This is how it refers to what binding it points to... Then binding definition contains type, which tell binding is for what port type..
Usually names of wsdl elements can be anything downwards.. But usually names are referred in attributes like binding, type, etc...

For example
<service> tag element name attribute can be anything..
<port> tag (within <service> tags) element name attribute can be anything but its binding attribute should point to the name of <binding> tag name attribute..

<binding> tag element name attrubte can be anything but its type attribute should point to the name of <portType> tag name attribue.

and it goes on like this...

In your given wsdl port element name can be anything so its correct but its not pointing to the correct binding type. i.e StockQuoteSoapBinding not to StockQuoteBinding.. May be the example you have taken from is not properly documented or overlooked. Not all internet sources are correct.

HTH..
[ January 17, 2007: Message edited by: Rizwan Mohammad ]
 
Femi Byte
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply.
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. I misspelt your name in my previos post.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic