on 01-30-2011 2:03 PM
These two classes can help you:
package com.moovit;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import org.apache.axis2.databinding.utils.ConverterUtil;
public class MyConverter extends ConverterUtil{
public static String convertToString(Calendar value)
{
SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
String a = zulu.format(value.getTime());
return a;
}
public static String convertToString(Date value) {
Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.setTime(value);
StringBuffer dateString = new StringBuffer(16);
appendDate(dateString, calendar);
return dateString.toString();
}
package com.moovit;
import java.rmi.RemoteException;
import java.util.Calendar;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.databinding.types.Token;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import com.sap.xi.appl.global2.HTTPServiceStub;
import com.sap.xi.appl.global2.HTTPServiceStub.BPERPByIDQryMsg_s;
import com.sap.xi.appl.global2.HTTPServiceStub.BPERPByIDQry_sSelByID;
import com.sap.xi.appl.global2.HTTPServiceStub.BPERPByIDRsp_sBPCom;
import com.sap.xi.appl.global2.HTTPServiceStub.BusinessDocumentMessageHeader;
import com.sap.xi.appl.global2.HTTPServiceStub.BusinessPartnerERPByIDQuery_sync;
import com.sap.xi.appl.global2.HTTPServiceStub.BusinessPartnerERPByIDResponseMessage_sync;
import com.sap.xi.appl.global2.HTTPServiceStub.BusinessPartnerInternalID;
import com.sap.xi.appl.global2.HTTPServiceStub.GLOBAL_DateTime;
import com.sap.xi.appl.global2.StandardMessageFault;
public class Test {
/**
@param args
*/
public static void main(String[] args) {
System.out.println("Starting Call to SAP");
try {
//We need to make sure our special data converter class is used
System.setProperty("adb.converterutil", "com.moovit.MyConverter");
//Declare the stub generated from the WSDL
HTTPServiceStub stub = new HTTPServiceStub();
//Two parameters are required
//1. The business Parter ID - This goes into the body of the request
BusinessPartnerInternalID businessPartnerInternalID = new BusinessPartnerInternalID();
Token token = new Token();
token.setValue("12");
businessPartnerInternalID.setBusinessPartnerInternalID(token);
//2. The Creation Date - indeed many issues here - This goes to the message header
Calendar rightNow = Calendar.getInstance();
GLOBAL_DateTime globalDateTime = new GLOBAL_DateTime();
globalDateTime.setGLOBAL_DateTime(rightNow);
//Create the message
BPERPByIDQryMsg_s bperpByIDQryMsg = new BPERPByIDQryMsg_s();
//Set business parter ID in the Message via the Query Object
BPERPByIDQry_sSelByID bperpByIDQry_sSelByID = new BPERPByIDQry_sSelByID();
bperpByIDQry_sSelByID.setInternalID(businessPartnerInternalID );
bperpByIDQryMsg.setBusinessPartnerSelectionByID(bperpByIDQry_sSelByID);
// Set Message Header passing globalDateTime
BusinessDocumentMessageHeader messageHeader = new BusinessDocumentMessageHeader();
messageHeader.setCreationDateTime(globalDateTime );
bperpByIDQryMsg.setMessageHeader(messageHeader );
//This sets the message into the operation
BusinessPartnerERPByIDQuery_sync businessPartnerERPByIDQuery_sync = new BusinessPartnerERPByIDQuery_sync();
businessPartnerERPByIDQuery_sync.setBusinessPartnerERPByIDQuery_sync(bperpByIDQryMsg);
//Provide the Authentication to the stub
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername("PXXXXXXX");
basicAuth.setPassword("YYYYYYYYY");
final Options clientOptions = stub._getServiceClient().getOptions();
clientOptions.setProperty(HTTPConstants.AUTHENTICATE, basicAuth);
try {
System.out.println("About to call SAP");
BusinessPartnerERPByIDResponseMessage_sync response = stub.businessPartnerERPByIDQueryResponse_In(businessPartnerERPByIDQuery_sync);
System.out.println("Call returned");
BPERPByIDRsp_sBPCom[] bperpByIDRsp_sBPCom = response.getBusinessPartnerERPByIDResponseMessage_sync().getBusinessPartner().getCommon();
System.out.println("The name of this customer is - " + bperpByIDRsp_sBPCom[0].getOrganisation().getName().getFirstLineName());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (StandardMessageFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//stub.businessPartnerERPByIDQueryResponse_In(businessPartnerERPByIDQuery_sync);
//System.out.println("Done declaring stub");
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Create the request
/* HTTPServiceStub. request = new
net.roseindia.HelloWorldServiceStub.SayHello();
request.setArgs0("Deepak Kumar");
//Invoke the service
net.roseindia.HelloWorldServiceStub.SayHelloResponse response
= stub.sayHello(request);
System.out.println("Response : " + response.get_return());
*/
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.