on 09-24-2010 3:19 AM
Hello Experts,
I'm quite new to using SOAP. I just want to ask how to call SOAP in JAVA specifically NetBean. I already created a webservice using the WSDL a created in SAP XI but problem is when I'm trying to invoke the webservice I always get error "401 Unathorized". Is there a way to specify the user name and password when calling the webservice via JAVA code?
Error Message:
Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized
Sample Code:
public class Main {
/**
@param args the command line arguments
*/
public static void main(String[] args) throws UnsupportedEncodingException {
ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT Req = new ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT();
Req.setCompanyCode(" ");
Req.setCustomerNumber("00110");
RespCustDetailsDT cdwsMI = cdwsMI(Req);
System.out.println("Customer :" + cdwsMI.getCustomerNumber());
System.out.println("Name :" + cdwsMI.getName());
System.out.println("Street :" + cdwsMI.getStreet());
System.out.println("Coutnry :" + cdwsMI.getCountry());
System.out.println("City :" + cdwsMI.getCity());
System.out.println("MSG Type :" + cdwsMI.getMessageType());
System.out.println("Message :" + cdwsMI.getReturnMessage());
}
private static RespCustDetailsDT cdwsMI(ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT reqCustomerNoMT) {
ph.co.amkor.atp.ppmodule.synch.CDWSMIService service = new ph.co.amkor.atp.ppmodule.synch.CDWSMIService();
ph.co.amkor.atp.ppmodule.synch.CDWSMI port = service.getCDWSMIPort();
return port.cdwsMI(reqCustomerNoMT);
}
}
SAP Netweaver Information
Session Information
Application:
Design: Integration Builder
User:
aafri
Logon Language:
Korean
Server:
atpxisd01_XD1_01
Server Node:
server0
Runtime Environment
Java version:
1.4.2_12
Java vendor:
Sun Microsystems Inc.
Version
Service pack:
12
Release:
NW04S_12_REL
Latest change:
29423
Sync time:
${sync.time}
Regards,
Alfred
can you try this
BindingProvider prov = (BindingProvider) port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "username");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello John Wu,
Points were given.
The code you gave me worked. Thanks! but now I'm having another error below. It seems that it did not returned anything at all cause cdwsMI object is null.
Error:
Exception in thread "main" java.lang.NullPointerException
at xiwebservice.Main.main(Main.java:31)
Java Result: 1
Line were error happened:
public class Main {
/**
@param args the command line arguments
*/
public static void main(String[] args) throws UnsupportedEncodingException {
ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT Req = new ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT();
Req.setCompanyCode(" ");
Req.setCustomerNumber("00110");
RespCustDetailsDT cdwsMI = cdwsMI(Req);
+System.out.println("Customer :" + cdwsMI.getCustomerNumber());+
System.out.println("Name :" + cdwsMI.getName());
System.out.println("Street :" + cdwsMI.getStreet());
System.out.println("Coutnry :" + cdwsMI.getCountry());
System.out.println("City :" + cdwsMI.getCity());
System.out.println("MSG Type :" + cdwsMI.getMessageType());
System.out.println("Message :" + cdwsMI.getReturnMessage());
}
private static RespCustDetailsDT cdwsMI(ph.co.amkor.atp.ppmodule.synch.ReqCustomerNoDT reqCustomerNoMT) {
ph.co.amkor.atp.ppmodule.synch.CDWSMIService service = new ph.co.amkor.atp.ppmodule.synch.CDWSMIService();
ph.co.amkor.atp.ppmodule.synch.CDWSMI port = service.getCDWSMIPort();
BindingProvider prov = (BindingProvider) port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "aafri");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "betanew3");
return port.cdwsMI(reqCustomerNoMT);
}
}
Regards,
Alfred
Hello John Wu,
It was successfully called when I've checked in communication channel monitoring and SXMB_MONI but I only see the request message but no response message. I believe this supposed to return a response since the setup is asynchronous. Alos noticed the the XML message it sent in SXMB_MONI message still has asynchronous stated and not synchronous.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!-- Response
-->
- <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SAP="http://sap.com/xi/XI/Message/30">
- <SOAP:Header>
- <SAP:Main xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://www.docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" versionMajor="003" versionMinor="000" SOAP:mustUnderstand="1" wsu:Id="wsuid-main-92ABE13F5C59AB7FE10000000A1551F7">
<SAP:MessageClass>ApplicationMessage</SAP:MessageClass>
<SAP:ProcessingMode>asynchronous</SAP:ProcessingMode>
<SAP:MessageId>05259730-C78D-11DF-9256-00144F6987BB</SAP:MessageId>
<SAP:TimeSent>2010-09-24T03:37:13Z</SAP:TimeSent>
+ <SAP:Sender>
Regards,
Alfred
but I only see the request message but no response message. I believe this supposed to return a response since the setup
is asynchronous.
You will get a response only when the setup is SYNCHRONOUS and not Asynchronous.....is your above statement a typo?
What have you selected as Quality of service in the SOAP Channel....it should be Best Effort.
Regards,
Abhishek.
I setup synchronous Message Interface in Integration Builder: Design.
This is fine....but what about the quality of service option in Sender SOAP Channel? Have you set it as Best Effort.
You said that that the request is reaching SAP....now can you confirm for SAP developer that SAP is able to process this request and also to generate the response?
What are you using on the SAP side...PROXY/ RFC? I hope that it is configured to work in SYNC mode.
Regards,
Abhishek.
Hello,
I am using RFC on SAP side specifically BAPI_CUSTOMER_GETDETAIL2. Setup is SOAP -> RFC. I already changed it just recently to Best Effort now I am having error in channel saying "error occured" after "request recieved" logs. Also below is the message returned by JAVA.
Error message in Java:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Server Error
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:119)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy28.cdwsMI(Unknown Source)
at xiwebservice.Main.cdwsMI(Main.java:47)
at xiwebservice.Main.main(Main.java:29)
Java Result: 1
Regards,
Alfred
Hi,
Below are the objects I've created.
Data Type:
ReqCustomerNo_DT
RespCustDetails_DT
Message Type:
ReqCustomerNo_MT -> using ReqCustomerNo_DT (Data Type)
RespCustDetails_MT -> using ReqCustomerNo_DT (RespCustDetails_DT)
Message Interface:
CDWS_MI -> synchronous/Outbound
Output Message : ReqCustomerNo_MT -> using ReqCustomerNo_DT (Data Type)
Input Message : RespCustDetails_MT -> using ReqCustomerNo_DT (RespCustDetails_DT)
Message Mapping:
Request_MM -> mapped ReqCustomerNo_MT with BAPI_CUSTOMER_GETDETAIL2(RFC)
Response_MM - mapped BAPI_CUSTOMER_GETDETAIL2.response (RFC) with RespCustDetails_MT
Interface Mapping:
CDWS_IM:
Source Interface -> CDWS_MI
Target Interface -> BAPI_CUSTOMER_GETDETAIL2
Messages:
Request: Mapping Program -> Request_MM
Source Message: ReqCustomerNo_MT
Target Message: BAPI_CUSTOMER_GETDETAIL2
Response: Mapping Program -> Response_MM
Source Message: BAPI_CUSTOMER_GETDETAIL2.Response
Target Message: RespCustDetails_MT
Regards,
Alfred
Hi,
Below are the objects created in ID.
Sender Agreement:
Service: ZBSBACKEND
Interface: CDWS_MI
Interface Namespace: http://atp.amkor.co.ph/ppmodule/synch
Receiver Determination:
Service: ZBSBACKEND
Interface: CDWS_MI
Interface Namespace: http://atp.amkor.co.ph/ppmodule/synch
Configured Receivers: ZBSBACKEND
Interface Determination:
Inbound Interface : BAPI_CUSTOMER_GETDETAIL2
Interface Mapping : CDWS_IM
Receiver Agreement:
Sender
Service: ZBSBACKEND
Receiver
Service: ZBSBACKEND
Interface: BAPI_CUSTOMER_GETDETAIL2
Interface namespace: urn:sap-com:document:sap:rfc:functions
Regards,
Alfred
Hello,
I think its just fine to use same Business system as stated in this forum. Someone said this below
"As mentioned above there is no need to create a Business System for entities outside your SLD boundaries.
You can create a Party in the ID, under that, create a Business Service for your SOAP Sender.
Under that Business Service you can define your SOAP Sender Communication Channel."
Regards,
Alfred
Can you guide me on how to set this up on SLD.
It is not to be set in SLD....only Business System is created in SLD.
Business Service is created in Integration Directory itself.
Integration Directory --> Right Click and select Business Service....assign a name and say create...then assign the Sender Sync Message Interface to this Business Service.
Delete the existing objects in Integration Directory (RD, ID, SA) you created for this interface.....then again redo the objects with this business service as sender
Regards,
Abhishek.
Hello,
Here are some details that basis found related to the error that I was talking about.
Runtime Errors DBIF_RSQL_SQL_ERROR
Exception CX_SY_OPEN_SQL_DB
Date and Time 28.09.2010 09:31:23
Short text
SQL error in the database when accessing a table.
What happened?
The database system detected a deadlock and avoided it by rolling back
your transaction.
What can you do?
If possible (and necessary), repeat the last database transaction in the
hope that locking the object will not result in another deadlock.
Note which actions and input led to the error.
For further help in handling the problem, contact your SAP administrator
.
You can use the ABAP dump analysis transaction ST22 to view and manage
termination messages, in particular for long term reference.
Note which actions and input led to the error.
For further help in handling the problem, contact your SAP administrator
.
You can use the ABAP dump analysis transaction ST22 to view and manage
termination messages, in particular for long term reference.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
in
procedure "DELETE_LUW_PACKET" "(FORM)", nor was it propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The database system recognized that your last operation on the database
would have led to a deadlock.
Therefore, your transaction was rolled back
to avoid this.
ORACLE always terminates any transaction that would result in deadlock.
The other transactions involved in this potential deadlock
are not affected by the termination.
Regards,
Edited by: alfred_A_sap on Sep 28, 2010 9:10 AM
Answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You have to pass user name and password of PI in JAVA Program.
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
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.