Java+axis the problems encountered in the process of calling ASP.net Web service by client and the solving method

Source: Internet
Author: User

Background: The company cooperates with an operator, the operator provides the interface document, the data flow is bidirectional in the document, the communication between the carrier and the company uses the Web service way, the two sides are mutually client and server side. The problem I encountered this time was when the operator's client invoked the Web service on my company's server. Need to specifically note that: operators have dozens of partners, so the client code can not be modified by a partner, the Web Service development environment of the partners are not the same, most of them are in the Java language development, and my company is developed with VS2005.
Process:
The part of the interface documentation involved is as follows:
User Data Synchronization (syncuserdata):
string font>

integer /font>

valign= "Top" width= " valign= "Top" width= "
index /p>

parameter Name /font>

req

type

size o:p>

1

/td>

mobile

user number

2

/td>

spid

m

string

21

partner identification

3

/td>

service span>

m /span>

21

business code

4

/td>

action span>

m /span>

4

user action

5

/td>

time

m

string /span>

14

timestamp

6

/td>

desc

m

string

255

reason description

7

Terminal

M

String

4

Terminal type


Carrier clients use the Web service client invocation that is implemented by the JAVA JDK 1.5+axis and provide specific debugging examples:

Package Smp.webservice.client;

Import java.rmi.RemoteException;

Import Javax.xml.namespace.QName;
Import javax.xml.rpc.ServiceException;

Import Org.apache.axis.client.Call;
Import Org.apache.axis.client.Service;

Public   class serviceclient ... {
Public intSyncuserdata (String Mobile, String SPID, String Service, Integer Action, String time, String Desc, string terminal, STR ing ServiceEndpoint)
throwsException...{
Object Result=NULL;
Try ...{
call called = this. Invokefunction ("syncuserdata" , ServiceEndpoint);
result =call.invoke (new object[] ... {Mobile, SPID, Service, Action, Time, Desc, terminal} );
} Catch(Exception e)...{
throw E;
}

Try...{
return ((Integer) result). Intvalue ();
}Catch(Exception e)...{
return Integer.parseint (( (String) result);
}
}

PublicCall invokefunction (String operationname, String serviceendpoint)
throwsserviceexception...{
Service service = serviceinstance.getinstance ();
Call Call = (call) Service.createcall ();
Call.settargetendpointaddress (ServiceEndpoint);
Call.setoperationname (new QName (OperationName));
return call ;
}

/** *//**
* Test the Client method
*/
Public Static voidMain (string[] args)...{
ServiceClient SC= Newserviceclient ();
String EndPoint= "Http://127.0.0.1/WebTest/Service.asmx";

Try ...{
int i=sc.syncuserdata ("13312345678",  "3735127", "834621", New Integer (8), "20080101120000" , "desc","9" , EndPoint);

System.out.println ("Result: " + i);
} Catch(Exception e)...{
E.printstacktrace ();
}
}
}

Where the value of endpoint is used to invoke the Web service address of my local. NET development.
I built the web with the C # language in asp.net
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.