發表文章

目前顯示的是 8月, 2013的文章

Set the max no. of port and tcp timeout on window

Run regedit Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters Create the following setting: value name: MaxUserPort value type: DWORD value: 65534 effective range: 5000-65534 default: 5000 value name: TCPTimedWaitDelay value type: DWORD value: 30

Solution for MongodbException: can't find a chunk! when using GridFS

public void insertFileByGridFS(byte[] data, ObjectId id, String filename) throws Exception{ GridFS gfs = new GridFS(database, "pdf"); GridFSInputFile gfsFile = gfs.createFile(data.clone()); gfsFile.setContentType("application/pdf"); //GridFS will set the parent file id for the chunk id by default. //if set the id by setId(new ObjectId()), the file_id of the chunk will be null gfsFile.setId(id); gfsFile.setFilename(filename); gfsFile.save(); } Please don't explicitly call GridFSInputFile.setId(), otherwise the file_id field of chunk will be null, you can't retrieve the file by GridFSDBFile.findOne(filename) (file name is store in the files collection and link to chunk collection by the file_id)

Invoking web services via proxy using JAX-RPC and JAX-WS

Invoking Web Services through a proxy using JAX-WS MyService service = null; service = new MyService(); MyServiceSoap port = service.getMyServiceSoap(); BindingProvider bp = (BindingProvider) port; Binding binding = bp.getBinding(); Map ctx = bp.getRequestContext(); ctx.put(BindingProvider.USERNAME_PROPERTY, "proxyuser"); ctx.put(BindingProvider.PASSWORD_PROPERTY, "proxypassword"); Note that we don't specify the Proxy Server here. JAX-WS sends authentication information for the proxy in request headers. Invoking Web Services through a proxy using JAX-WS private HttpTransportInfo getHttpInfo() { Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyServer", 9090)); HttpTransportInfo httpInfo = new HttpTransportInfo(); httpInfo.setProxy(proxy); httpInfo.setProxyUsername("proxyuser".getBytes()); httpInfo.setProxyPassword("proxypassword".getBytes()); ret