If you are using a provider, the Message Factory creating the message includes the endpoint specification in the message header.
If you do not use a provider, you can specify the endpoint as a parameter to the SOAPConnection.call method, which you use to send a SOAP message.