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>
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> | valign= "Top" width= "
21 |
business code |
4 /td> |
action span> |
m /span> | valign= "Top" width= "
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