0

I'm trying to send a soap request to a WSE 3.0 service but can't get the request to work. It's working great when there is a direct connection between computer A and B. When there is a NAT device between them (A -> NAT -> B), I get an error in the event log on computer B:

Message Dispatch Failure: 
<soap:Envelope
xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
    <wsa:Action>http://tempuri.org/GetMachineQueue</wsa:Action 
    <wsa:MessageID>urn:uuid:b8acf70a-74e8-4352-8d65-b5ba40ecf446</wsa:MessageID>
    <wsa:ReplyTo 
        <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
    </wsa:ReplyTo>
    <wsa:To>soap.tcp://192.168.56.1:6040/EquipmentService</wsa:To>
    <wsse:Security>
        <wsu:Timestamp wsu:Id="Timestamp-a1bc6b7d-6dea-4bac-97c2-6750f68699e1">
            <wsu:Created>2022-12-22T09:50:21Z</wsu:Created>
            <wsu:Expires>2022-12-22T09:55:21Z</wsu:Expires>
        </wsu:Timestamp>
    </wsse:Security>
</soap:Header>
<soap:Body>
    <GetMachineQueue
        xmlns="http://tempuri.org/">
        <sMachine>Virtualbox</sMachine>
    </GetMachineQueue>
</soap:Body>
</soap:Envelope>

I also get a exception from the service proxy class in C#:

GetMachineQueue Exception: System.Web.Services.Protocols.SoapHeaderException: Destination Unreachable

From what I understand the problem is that the "wsa:To" tag is pointing at the NAT device and not the final destination. But I have to point the request to the NAT to come to computer B. The NAT device uses port forwarding to forward the request to computer B. When we have a A -> B setup this code works fine:

EquipmentService client = new EquipmentService();
var machineAddress = GetUri(sMachine);
client.Url = machineAddress;
client.GetMachineQueue(sMachine);

But that doesn't work when doing A -> NAT -> B. I have temporarily solved this by adding this code:

EquipmentService client = new EquipmentService();
var (machineAddress, natAddress) = GetUri(sMachine);
client.Url = machineAddress;
client.Destination.Via = new Microsoft.Web.Services3.Referral.Via(new Uri(natAddress));
client.Destination.Address = new Microsoft.Web.Services3.Addressing.Address(new Uri(machineAddress));
client.GetMachineQueue(sMachine);

I feel this is a bad way of solving the problem tho since what happens if there are more nodes that is has to pass before reaching its destination? Is there any way I can configure the request to automatically "redirect" or something?..

Teh Swish
  • 99
  • 1
  • 12

0 Answers0