0

So reading JBoss administration guide I see that WS-addressing is used to create "stateful endpoints."

I understand that WS-addressing creates a standard for specifying the messaging routing data within the SOAP headers of a web service... but I'm not sure how that relates to the state of the endpoints.

Here is something from Wikipedia:

WS-Addressing supports the use of asynchronous interactions by specifying a common SOAP header (wsa:ReplyTo) that contains the endpoint reference (EPR) to which the response is to be sent. The service provider transmits the response message over a separate connection to the wsa:ReplyTo endpoint. This decouples the lifetime of the SOAP request/response interaction from the lifetime of the HTTP request/response protocol, thus enabling long-running interactions that can span arbitrary periods of time.

So wsa:ReplyTo gives you the ability to do things asynchronously because you have a way to get your response to the right place even though the HTTP request is done.

I'm still failing to see where the "State" comes in.

Any insight on this?

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152

1 Answers1

0

I get it now. It makes sense when you look at a code example. Here, extracted from the JBoss Admin guide, is an example StatefulEndpoint WebService:

@WebService(name = "StatefulEndpoint", targetNamespace = "http://org.jboss.ws/sam ples/wsaddressing", serviceName = "TestService")
@Addressing(enabled=true, required=true)
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class StatefulEndpoint implements StatefulEndpoint, ServiceLifecycle
{
@WebMethod
public void addItem (String item )
{ ... }
@WebMethod
public String getItemsInCart()
{ ... }
}

Then the web service client creates two separate ports

port1 = (StatefulEndpoint)service.getPort(StatefulEndpoint.class, new
javax.xml.ws.soap.AddressingFeature());
port2 = (StatefulEndpoint)service.getPort(StatefulEndpoint.class, new
javax.xml.ws.soap.AddressingFeature());

Passing in a new AddressingFeature into the getPort function will enable the WS-addressing functionality.

Here is the code that demonstrates the statefulness for the two ports we just created:

public class AddressingStatefulTestCase extends JBossWSTest
{
...
public void testAddItem() throws Exception
{
port1.addItem ("Ice Cream ");
port1.addItem ("Ferrari");
port2.addItem ("Mars Bar");
port2.addItem ("Porsche");
}
public void testGetItems() throws Exception
{
String items1 = port1.getItems();
assertEquals("[Ice Cream , Ferrari]", item s1);
String items2 = port2.getItems();
assertEquals("[Mars Bar, Porsche]", item s2);
}
}

Note that port1 added different items than port2 did, but when port1 calls getItems... it gets only the items that it added, not the ones from port2. This is what gives it the state.

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152