0

i'm programming an interface for a Staeubli Robot Controller (CS8). Everything runs smooth until i try to request some IO information. The request ends with SOAP_EOF. I tried a few other request an they all just work fine. So i captured the send/received packages and the only difference between the good requests and the bad one is the mime-type of the response. Here is the request/response of the bad one:

Request

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
    xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ns3="http://www.w3.org/2004/08/xop/include"
    xmlns:ns4="http://www.w3.org/2004/11/xmlmime"
    xmlns:ns5="http://tempuri.org/xmlmime.xsd"
    xmlns:ns1="CS8ServerV0"
    xmlns:ns2="urn:CS8ServerV1"
    xmlns:ns6="urn:CS8ServerV2" 
    xmlns:ns7="urn:CS8ServerV3">
    <SOAP-ENV:Header>
        <ns1:sessionId SOAP-ENV:mustUnderstand="true">18638456</ns1:sessionId>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns6:getAllPhysicalIos></ns6:getAllPhysicalIos>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Response

--==pj+EhsWuSQJxx7przmb8HM+ZkeNcG3HezSNID7LmfDa9J4lfdUL8W1F7TNJK==
Content-Type: application/xop+xml; charset=utf-8; type="application/soap+xml; charset=utf-8"
Content-Transfer-Encoding: binary
Content-ID: <SOAP-ENV:Envelope>

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
    xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:SCSV0="CS8ServerV0"
    xmlns:xop="http://www.w3.org/2004/08/xop/include"
    xmlns:xmlmime="http://tempuri.org/xmlmime.xsd"
    xmlns:SCSV1="urn:CS8ServerV1"
    xmlns:SCSV2="urn:CS8ServerV2">
    <SOAP-ENV:Header>
        <SCSV0:sessionId>18638456</SCSV0:sessionId>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <SCSV2:getAllPhysicalIosResponse>
            <data xmlmime:contentType="text/xml">
                <data><xop:Include href="cid:id1"/></data>
            </data>
        </SCSV2:getAllPhysicalIosResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

--==pj+EhsWuSQJxx7przmb8HM+ZkeNcG3HezSNID7LmfDa9J4lfdUL8W1F7TNJK==
Content-Type: text/xml
Content-Transfer-Encoding: binary
Content-ID: <id1>

<?xml version="1.0" encoding="utf-8"?>
<PhysicalIos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.staubli.com/robotics/PhysicalIos/1" >
    <Io name="usrIn0" desc="" type="din" />
    <Io name="usrIn1" desc="" type="din" />
    <Io name="MOTOR_1_3_5" desc="" type="din" />
    <Io name="MOTOR_2_4_6" desc="" type="din" />
    <Io name="CASTING" desc="" type="din" />
    <Io name="DSI_BOARD" desc="" type="din" />
    <Io name="GLOBAL_PTC" desc="" type="din" />
    <Io name="fIn0" desc="" type="din" />
    <Io name="fIn1" desc="" type="din" />
    <Io name="SECTEUR_OK" desc="" type="din" />
    <Io name="valve1" desc="" type="dout" />
    <Io name="valve2" desc="" type="dout" />
    <Io name="fOut0" desc="" type="dout" />
    <Io name="CBT_TEMP" desc="" type="ain" />
    <Io name="CPU_TEMP" desc="" type="ain" />
    <Io name="Socket\test" desc="" type="socketClient" />
</PhysicalIos>

--==pj+EhsWuSQJxx7przmb8HM+ZkeNcG3HezSNID7LmfDa9J4lfdUL8W1F7TNJK==--

SOAP fault

SOAP 1.2 fault: SOAP-ENV:Sender [no subcode]
"End of file or no input: Operation interrupted or timed out"
Detail: [no detail] 

SOAP error code = SOAP_EOF (== -1)

Maybe someone sees my fault?

If any information is missing, please feel free to comment.

Thanks in advance!

EDIT1

I also logged the gSOAP connection. Here is the related log entry:

HTTP status: HTTP/1.1 200 OK
HTTP header: Server: gSOAP/2.7
HTTP header: Content-Type: multipart/related; boundary="==IhAUx7qlRoBMWpLHXMvxVdaVBbhA+poanGC1U/anZjRVQ4oRZshmeOhwc+Zx=="; type="application/xop+xml"; start="<SOAP-ENV:Envelope>"; start-info="application/soap+xml; charset=utf-8"
../soaptest/source/stdsoap2.cpp(7330): malloc(224) = 0xbe6290
../soaptest/source/stdsoap2.cpp(7330): malloc(88) = 0xab3170
../soaptest/source/stdsoap2.cpp(7330): malloc(40) = 0xbe5ae0
HTTP header: Transfer-Encoding: chunked
HTTP header: Connection: keep-alive
Finished HTTP header parsing, status = 200
Keep alive connection = 1
Getting chunk size (idx=307 len=307)
Read 5 bytes from socket=21/fd=0
Chunk size = 81E (hex)
Moving buf len to idx=5 len=2083 (81E)
Passed end of buffer for chunked HTTP (0 bytes left)
Getting chunk: read 1448 bytes
../soaptest/source/stdsoap2.cpp(7330): malloc(96) = 0xab2ef0
MIME header: Content-Type: application/xop+xml; charset=utf-8; type="application/soap+xml; charset=utf-8"
../soaptest/source/stdsoap2.cpp(7330): malloc(104) = 0xbe6380
MIME header: Content-Transfer-Encoding: binary
MIME header: Content-ID: <SOAP-ENV:Envelope>
../soaptest/source/stdsoap2.cpp(7330): malloc(40) = 0xbe63f0
XML PI <?xml version="1.0" encoding="UTF-8"?>
Switching to utf-8 encoding
../soaptest/source/stdsoap2.cpp(10357): malloc(62) = 0xbe5d60
Enlarging look-aside buffer to append data, old size=0, new size=256
../soaptest/source/stdsoap2.cpp(10160): malloc(256) = 0xaf89e0
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xaf8c00
../soaptest/source/stdsoap2.cpp(2735): malloc(40) = 0xbe64e0
Push namespace binding (level=0) 'SOAP-ENV' 'http://www.w3.org/2003/05/soap-envelope'
Push OK ('SOAP-ENV' matches 'SOAP-ENV' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(62) = 0xbe5b40
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe5340
../soaptest/source/stdsoap2.cpp(2735): malloc(40) = 0xbe65a0
Push namespace binding (level=0) 'SOAP-ENC' 'http://www.w3.org/2003/05/soap-encoding'
Push OK ('SOAP-ENC' matches 'SOAP-ENC' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(57) = 0xbe5920
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe5560
../soaptest/source/stdsoap2.cpp(2735): malloc(35) = 0xbe6660
Push namespace binding (level=0) 'xsi' 'http://www.w3.org/2001/XMLSchema-instance'
Push OK ('xsi' matches 'xsi' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(57) = 0xbe5700
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe5780
../soaptest/source/stdsoap2.cpp(2735): malloc(35) = 0xbe6720
Push namespace binding (level=0) 'xsd' 'http://www.w3.org/2001/XMLSchema'
Push OK ('xsd' matches 'xsd' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(59) = 0xbe54e0
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe59a0
../soaptest/source/stdsoap2.cpp(2735): malloc(37) = 0xbe67e0
Push namespace binding (level=0) 'SCSV0' 'CS8ServerV0'
Push OK ('SCSV0' matches 'ns1' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(57) = 0xaf8da0
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe5bc0
../soaptest/source/stdsoap2.cpp(2735): malloc(35) = 0xbe68a0
Push namespace binding (level=0) 'xop' 'http://www.w3.org/2004/08/xop/include'
Push OK ('xop' matches 'ns3' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(61) = 0xaf8b80
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe5de0
../soaptest/source/stdsoap2.cpp(2735): malloc(39) = 0xbe6960
Push namespace binding (level=0) 'xmlmime' 'http://tempuri.org/xmlmime.xsd'
Push OK ('xmlmime' matches 'ns5' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(59) = 0xab2e70
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe6000
../soaptest/source/stdsoap2.cpp(2735): malloc(37) = 0xbe6a20
Push namespace binding (level=0) 'SCSV1' 'urn:CS8ServerV1'
Push OK ('SCSV1' matches 'ns2' in namespace table)
../soaptest/source/stdsoap2.cpp(10357): malloc(59) = 0xbe6a80
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xab3030
../soaptest/source/stdsoap2.cpp(2735): malloc(37) = 0xbe6b30
Push namespace binding (level=0) 'SCSV2' 'urn:CS8ServerV2'
Push OK ('SCSV2' matches 'ns6' in namespace table)
Tags and (default) namespaces match: 'SOAP-ENV:Envelope' 'SOAP-ENV:Envelope'
Begin element found (level=1) 'SOAP-ENV:Envelope'='SOAP-ENV:Envelope'
../soaptest/source/stdsoap2.cpp(14903): malloc(40) = 0xbe6b90
Tags and (default) namespaces match: 'SOAP-ENV:Header' 'SOAP-ENV:Header'
Begin element found (level=2) 'SOAP-ENV:Header'='SOAP-ENV:Header'
Enter id='' type=296 loc=(nil) size=8 level=0
../soaptest/source/stdsoap2.cpp(7330): malloc(32) = 0xbe6bf0
Tags and (default) namespaces match: 'SCSV0:sessionId' 'ns1:sessionId'
Begin element found (level=3) 'SCSV0:sessionId'='ns1:sessionId'
Reverting to last element 'SCSV0:sessionId' (level=2)
Tags and (default) namespaces match: 'SCSV0:sessionId' 'ns1:sessionId'
Begin element found (level=3) 'SCSV0:sessionId'='ns1:sessionId'
Enter id='' type=206 loc=(nil) size=4 level=0
../soaptest/source/stdsoap2.cpp(7330): malloc(24) = 0xbe6c50
Element content value='18714240'
End element found (level=3) 'SCSV0:sessionId'='ns1:sessionId'
End element found (level=2) 'SOAP-ENV:Header'='SOAP-ENV:Header'
Tags and (default) namespaces match: 'SOAP-ENV:Body' 'SOAP-ENV:Body'
Begin element found (level=2) 'SOAP-ENV:Body'='SOAP-ENV:Body'
Tags and (default) namespaces match: 'SCSV2:getAllPhysicalIosResponse' 'ns6:getAllPhysicalIosResponse'
Begin element found (level=3) 'SCSV2:getAllPhysicalIosResponse'='ns6:getAllPhysicalIosResponse'
Enter id='' type=166 loc=0xab3010 size=24 level=0
../soaptest/source/stdsoap2.cpp(10357): malloc(67) = 0xbe6ca0
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe6d20
Tags match: 'data' 'data'
Begin element found (level=4) 'data'='data'
Reverting to last element 'data' (level=3)
soap_instantiate_ns6__MimeData(-1, , )
../soaptest/source/stdsoap2.cpp(7617): malloc(32) = 0xbe6e60
Instantiated location=0xbe6ec0
Tags match: 'data' 'data'
Begin element found (level=4) 'data'='data'
Enter id='' type=97 loc=0xbe6ec0 size=80 level=0
Tags and (default) namespaces match: 'xmlmime:contentType' 'ns5:contentType'
../soaptest/source/stdsoap2.cpp(7330): malloc(32) = 0xbe6f20
soap_instantiate_std__string(-1, , )
../soaptest/source/stdsoap2.cpp(7617): malloc(32) = 0xbe6f80
Instantiated location=0xbe6fe0
Tags match: 'data' 'data'
Begin element found (level=5) 'data'='data'
Enter id='' type=10 loc=0xbe6ec8 size=56 level=0
../soaptest/source/stdsoap2.cpp(10357): malloc(52) = 0xbe7030
../soaptest/source/stdsoap2.cpp(10412): malloc(256) = 0xbe70a0
Tags 'xop:Include' and 'xop:Include' match but namespaces differ
End element found (level=5) 'data'='data'
End element found (level=4) 'SCSV2:getAllPhysicalIosResponse'='data'
End element found (level=3) 'SOAP-ENV:Body'='ns6:getAllPhysicalIosResponse'
End element found (level=2) 'SOAP-ENV:Envelope'='SOAP-ENV:Body'
XML PI <?xml version="1.0" encoding="utf-8"?>
Switching to utf-8 encoding
Getting chunk: read 630 bytes
Read 7 bytes (chunked) from socket 21
Getting chunk size (idx=0 len=7)
Chunk size = 0 (hex)
End of chunked message
Shutdown socket 21 how=2
Close socket 21
soap_instantiate_SOAP_ENV__Fault(-1, , )
../soaptest/source/stdsoap2.cpp(7617): malloc(32) = 0xbe71e0
Instantiated location=0xbe7240
soap_instantiate_SOAP_ENV__Code(-1, , )
../soaptest/source/stdsoap2.cpp(7617): malloc(32) = 0xbe7290
Instantiated location=0xbe72f0
soap_instantiate_SOAP_ENV__Reason(-1, , )
../soaptest/source/stdsoap2.cpp(7617): malloc(32) = 0xbe7310
Instantiated location=0xbe7370

SOLUTION

So i studied the log files line by line and found something interesting. Related line:

Tags 'xop:Include' and 'xop:Include' match but namespaces differ

This means soap doesn't parse the idx field within the response. Instead it uses:

MIME header: Content-ID: <SOAP-ENV:Envelope>

This is definitely wrong.

So i thought, something must be wrong with the XML namespace the server is using. By ignoring the namespace faults it works.

I used the following IO_MODE for the socket connection: #define MY_IO_MODE (IO_MODE | SOAP_ENC_MTOM | SOAP_XML_IGNOREN)

Now it looks quite better:

MIME header: Content-ID: <id1>

Despite knowing that ignoring format/famespace errors is not good programming style, i had no choice but keeping them as I have no influence on the server side.

Thanks to all readers!

user2957270
  • 11
  • 1
  • 4

1 Answers1

0

I see this is an HTTP keep-alive connection. When the next message does not arrive and the connection is closed by the peer then you will receive an EOF. Best is to set the IO timeouts (connect_timeout, send_timeout, recv_timeout) and check after EOF is soap.errnum == 0 which means the connection timed out. Also, make sure to use the latest 2.8.16 release. An issue with MIME attachments appears to have occurred some releases ago but has been resolved.

Dr. Alex RE
  • 1,772
  • 1
  • 15
  • 23
  • I updated my gsoap version to 2.8.16, set the timeouts to 10s (which is quit unreachable) but nothing helps. Finally i found the solution. I will update my question above. Thanks you all. – user2957270 Nov 23 '13 at 11:23