Java-generated webservice requires that Authorization:basic xxxxxxxxxxxxxxx authentication information be brought in the header of HTTP at the time of invocation
Since the service is called directly after adding the Web reference, rewrite the service class, overriding the GetWebRequest method of the service class, as shown in the example code
public class Myservice:xxx service class {public myservice (string url) { url = URL; } protected override WebRequest GetWebRequest (Uri uri) {HttpWebRequest request = (HttpWebRequest ) base. GetWebRequest (URI); if (preauthenticate)///use, you must set the PreAuthenticate property of the service class to true and set the credentials property {NetworkCredential Net Workcredential = base. Credentials.getcredential (URI, "Basic"); if (networkcredential! = null) {byte[] Credentialbuffer = new UTF8Encoding (). GetBytes (NetworkCredential. UserName + ":" + networkcredential. Password); Request. headers["Authorization"] = "Basic" + convert.tobase64string (Credentialbuffer); } else throw new ApplicationException ("No Network Credentials"); } return request; }}
Reference information:
http://stackoverflow.com/questions/20495105/basic-authentication-in-php-webservice-with-c/20517700#20517700
http://stackoverflow.com/questions/897782/ how-to-add-custom-http-header-for-c-sharp-web-service-client-consuming-axis-1-4/1712795#1712795
C # Method of adding SHENFA authentication information when calling Java WebService