You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by sa...@123india.com on 2001/04/26 06:57:25 UTC
XMethod Problem
Dear Mr. Ashok,
I developed a TempClient (see below) class as per u'r suggestion.
But I am getting the Error like:
**************************** Error*****************
[SOAPException: faultCode=SOAP-ENV:Protocol; msg=Unsupported response content ty
pe "text/html", must be: "text/xml". Response was:
<html><head><title>Error 407</title>
<meta name="robots" content="noindex">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"></head>
<body>
<h2>HTTP Error 407</h2>
<p><strong>407 Proxy Authentication Required</strong></p>
<p>You must authenticate with a proxy server before this request can be serviced
. Please log on to your proxy server, and then try again.</p>
<p>Please contact the Web server's administrator if this problem persists.</p>
</body></html>
]
at org.apache.soap.rpc.Call.getEnvelopeString(Call.java:173)
at org.apache.soap.rpc.Call.invoke(Call.java:210)
at TempClient.getTemp(TempClient.java:39)
at TempClient.main(TempClient.java:59)
****************************End of Error*****************
****************************Java Code*******************
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import org.apache.soap.transport.http.SOAPHTTPConnection;
public class TempClient{
public static float getTemp (URL url, String zipcode) throws Exception {
SOAPHTTPConnection conn = new SOAPHTTPConnection();
conn.setProxyHost("proxy IP");
conn.setProxyPort(80);
conn.setUserName("ID");
conn.setPassword("Paswd");
Call call = new Call ();
call.setSOAPTransport(conn);
// Service uses standard SOAP encoding
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
call.setEncodingStyleURI(encodingStyleURI);
// Set service locator parameters
call.setTargetObjectURI ("urn:xmethods-Temperature");
call.setMethodName ("getTemp");
// Create input parameter vector
Vector params = new Vector ();
params.addElement (new Parameter("zipcode", String.class, zipcode, null));
call.setParams (params);
// Invoke the service ....
Response resp = call.invoke (url,"");
// ... and evaluate the response
if (resp.generatedFault ()) {
throw new Exception();
} else {
// Call was successful. Extract response parameter and return result
Parameter result = resp.getReturnValue ();
Float rate=(Float) result.getValue();
return rate.floatValue();
}
}
// Driver to illustrate service invocation
public static void main(String[] args)
{
try
{
URL url=new URL("http://services.xmethods.com:80/soap/servlet/rpcrouter");
String zipcode= "94041";
float temp = getTemp(url,zipcode);
System.out.println(temp);
}
catch (Exception e) {e.printStackTrace();}
}
}
********************End of Jav Code************************
Please see it and suggest me the solution.
By using the same user I.D and Passwd I am able to connect to the site using browser.
TIA
S.S.Rao
______________________________________________________
123India.com - India's Premier Portal
Get your Free Email Account at http://www.123india.com
---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org