0

我正在使用网络服务。我使用 eclipse 编写了一个轴 1.4 的客户端。我可以通过 ssl vpn 访问网络服务。我的轴客户端代码工作正常。但是,代码必须在 android 设备上运行。我不能在 android 上使用轴代码,因为 android 不支持 java rmi。我正在尝试通过使用 apache httpclient 库制作 httppost 来使用服务。为了查看轴请求值,我使用了 tcpmon。它帮助我轻松编写 httppost 代码。问题是,当我不使用 tcpmon 直接运行代码时,它会给我以下错误:

Exception in thread "main" java.net.SocketException: Invalid argument: setsockopt
at java.net.DualStackPlainSocketImpl.setIntOption(Native Method)
at java.net.DualStackPlainSocketImpl.socketSetOption(Unknown Source)
at java.net.AbstractPlainSocketImpl.setOption(Unknown Source)
at java.net.PlainSocketImpl.setOption(Unknown Source)
at java.net.Socket.setTcpNoDelay(Unknown Source)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.prepareSocket(DefaultClientConnectionOperator.java:254)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:185)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at TTIncidentClient.main(TTIncidentClient.java:56)

如果我通过 tcpmon 发送请求,它可以工作。我得到了回应。我在下面给你 tcpmon 输出:

要求:

POST http://localhost:3333/SM/7/ws HTTP/1.1
SOAPAction: RetrieveList
Accept: application/soap+xml, application/dime, multipart/related, text/*
Pragma: no-cache
Cache-Control: no-cache
Authorization: Basic bW9iaXNlbTpPeXAlPzIwMTM=
Content-Length: 456
Content-Type: text/xml; charset=ISO-8859-1
Host: 10.6.105.132:3333
Proxy-Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.2.5 (java 1.5)

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><RetrieveIncidentListRequest xmlns="http://schemas.hp.com/SM/7"><keys query="flag=true and category=&quot;incident&quot; and assignee.name=&quot;xx.yy&quot;"/></RetrieveIncidentListRequest></soapenv:Body></soapenv:Envelope>

回复:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=AF8B0B75ED768852E44D7CB49DB5DD88; Path=/SM
Keep-Alive: timeout=1200000, max=1000
Connection: Keep-Alive
Content-Type: text/xml;charset=utf-8
Content-Length: 2009
Date: Sun, 11 Aug 2013 22:12:17 GMT

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><RetrieveIncidentListResponse message="Success" returnCode="0" schemaRevisionDate="2012-11-12" schemaRevisionLevel="0" status="SUCCESS" xmlns="http://schemas.hp.com/SM/7" xmlns:cmn="http://schemas.hp.com/SM/7/Common" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.hp.com/SM/7 http://testsc:3333/SM/7/Incident.xsd">......</SOAP-ENV:Body></SOAP-ENV:Envelope>

通常我希望 tcpmon 行为必须与我的本地行为相同,但 tcpmon 会改变结果。可能是什么原因?

4

1 回答 1

0

非常有趣的是,我没有使用 apache httpclient 或 java urlconnection 库,而是为soap 编写了套接字编程代码,就像在这个例子中一样。:)

于 2013-08-14T20:43:32.367 回答