I have generated stubs using Apache CXF, IBM Jax-WS and Axis as well in Eclipse and RAD 7.0 .
In all the 3 above scenarios it gives me the following exception
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: ARERR [149] A user name must be supplied in the control record
After searching i concluded that i have to add Authentication Info to the Soap header created by Client Stubs.
i tried the answer on this link
How do you add a Soap Header defined in a wsdl to a web service client in CXF?
but couldn't succeed. I am newbie to SOAP and WebServices
So if anyone has worked on it kindly Help.
I had this problem a few days ago and it was a headache for me. When generating the stubs you have to add a the flag -XadditionalHeaders to the wsimport command.
"C:\Program Files\Java\jdk1.X.X_XX\bin\wsimport.exe" -p com.company.package -keep -XadditionalHeaders -d folder1 http://mywsdllocation.com/doc.wsdl
Where:
-p: package that will contain generated classes
-keep: keep .java files (otherwise tou'll only get .class files)
-XadditionalHeaders: classes for authentication will be created
-d: Folder where generated classes will be placed.
After that, you only have to copy generated java files to your project, under the picked package (com.company.package in this case). Then you have you create an AuthenticationInfo object and inserting it in the stub method's call, something like this:
WSService service = new WSService();
WSPortTypePortType port = service.WSPortTypeSoap();
AuthenticationInfo auth = new AuthenticationInfo();
auth.setUserName(yourUsername);
auth.setPassword(yourPassword);
port.method(param1,param2,auth);
Hope it helps!
Related
Sorry if this is a duplicate, I looked at several other questions but none seemed to match or provide workable solutions.
Problem
I am writing a Spring Boot (v2.0.2) app, this app exposes a RESTful API which then calls into a WSDL service. I've generated the WSDL classes with Maven/jaxb plugin and everything works from my dev machine. When deployed to the server I get an error that the WSDL service class can not load the underlying WSDL file. The problem is that when the Java classes are generated it is using the full path from my dev machine (snippet from the generated service class)
try {
URL baseUrl;
baseUrl = com.mytest.WSDLService.class.getResource(".");
url = new URL(baseUrl, "/home/users/me/projects/wsdltest/wsdl/MyWSDL.wsdl");
} catch (MalformedURLException e) {
The WSDL file (MyWSDL.wsdl) is in the spring boot JAR file for my application, it is in a subdirectory off root called 'wsdl'
Question Is there a way that I can load this WSDL from the JAR file without having to modify the generated classes?
Ideal Solution I'm hoping to find a solution that doesn't make me modify the generated files (we intend to do this for several services), ideally I'd like a solution which can be done at build time (in the pom.xml?), if that's possible.
Solutions Tried
A post on here suggested using the "wsdlLocation" tag in my pom.xml and provide a explicit path to the WSDL file, e.g. <wsdlLocation>/wsdl/MyWSDL.wsdl</wsdlLocation>
Tried most of the solutions from this thread
Thanks in advance
I think I was able to find a solution thanks to this SO Thread. Evidently the answer depends on the version of the jaxws tool being used in maven (jaxws-maven-plugin). The project (which I inherited) explicitly asked for version 1.12 (which invoked JAX-WS RI 2.1.7-b01-), using this version of the tools I was able to use the '<wsdlLocation>classpath:wsdl/MyWSDL.wsdl</wsdlLocation>' solution in the thread mentioned. Once I noticed that the pom was using an explicit version I removed that the jaxws was updated (using JAX-WS RI 2.2.10) but then the 'classpath' solution stopped working. I switched to the other option mentioned in the thread '<wsdlLocation>/wsdl/MyWSDL.wsdl</wsdlLocation>'
I did a quick test and this seemed to have solved the problem (in both my dev machine and my test site).
Thank you
I am trying to use Oracle Sales Cloud web services. Web services have been consumed using wsimport and resultant jars have been added to the application.
wsimport command used for import:
wsimport.exe -keep -clientjar PartnerService.jar https://cbdy-test.crm.us2.oraclecloud.com/partnerCenterCorePublicModel/PartnerService?WSDL
The jar builds with warnings. Same process was done for a total of 8 Oracle webservices.
Howeever when attempting to access the web services via the wsimport generated jar error's are thrown for 2 web servies out of 8.
Java snippet:
14.PartnerService_Service partnerService_Service = new PartnerService_Service(new URL("https://cbdy-test.crm.us2.oraclecloud.com/partnerCenterCorePublicModel/PartnerService?WSDL"));
15.PartnerService partnerService = partnerService_Service.getPartnerServiceSoapHttpPort();
16.Map<String, Object> requestCredentails = ((BindingProvider) partnerService).getRequestContext();
17.requestCredentails.put(BindingProvider.USERNAME_PROPERTY, "#######");
18.requestCredentails.put(BindingProvider.PASSWORD_PROPERTY, "#######");
Exception:
Exception in thread "main" com.sun.xml.internal.ws.spi.db.DatabindingException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 17 counts of IllegalAnnotationExceptions
There's no ObjectFactory with an #XmlElementDecl for the element {http://xmlns.oracle.com/apps/cdm/foundation/parties/contactPointService/}OrigSystemReference.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement com.oracle.xmlns.apps.cdm.foundation.parties.contactpointservice.Edi.origSystemReference
at com.oracle.xmlns.apps.cdm.foundation.parties.contactpointservice.Edi
at protected java.util.List com.oracle.xmlns.apps.cdm.foundation.parties.organizationservice.OrganizationParty.edi
at com.oracle.xmlns.apps.cdm.foundation.parties.organizationservice.OrganizationParty
at public javax.xml.bind.JAXBElement com.oracle.xmlns.apps.cdm.foundation.parties.organizationservice.ObjectFactory.createOrganizationPartySourceSystemReferenceValue(java.lang.String)
at com.oracle.xmlns.apps.cdm.foundation.parties.organizationservice.ObjectFactory
....
at javax.xml.ws.Service.getPort(Unknown Source)
at com.oracle.xmlns.apps.partnermgmt.partnercenter.PartnerService_Service.getPartnerServiceSoapHttpPort(PartnerService_Service.java:68)
at com.oscservice.Dummy.main(Dummy.java:15)
I referred about this issue here and few other stackoverflow posts but i am unable to resolve this problem for the problematic web services.
Any pointers that would help in resolution would be helpful.
I was able to go past the issue in the question.
The block of code calling web service call was working in a new project and in a different class within the same project.
The problem seems to originate from the way the project is built.
I built a new project step by step with the old code and the error didn't occur.
I have generated webservice client proxy using wsdl in jdeveloper. I got all generated class and able to make a webservice call.
But when I try to patch these java files to production instance, the class file for package-info.java is not getting generated, so getting the exception while creating the jar file.
If i remove package-info.java class manually, getting the error saying, "Client received SOAP Fault from server : Failure in SDOSerializer.deserialize." .
Is there anyway, that I can remove the package-info.java file and its dependencies, with out getting any error? or any other suggestions?
I have created two webservices clients in NetBeans 7.1, mimicking the tutorial they have on their website.
I had done the first one a while ago against a wsdl file located at a http location, and had no problem using the webservice
The webservice I am working with at the moment has a wsdl file located at a https location. The setup of the service went off without a hitch. The only difference with the first one was a popup alerting me to a security certificate, which I accepted. Service, Generated Sources, META-INF etc are all created successfully. A local copy of the wsdl file is stored on my pc under the src/.. folder.
However, as soon as I go to run my code, I receive this error:
Cannot find 'https://-domain-.net/-XYZServices-/-ABCXML?wsdl-'
wsdl. Place the resource correctly in the classpath.
I found several similar issues in Stackoverflow and other places online, but nothing that really addressed my problem. I tried several suggestions anyway:
I checked the jax-ws-catalog.xml file, and found the url quoted above mapped to the local folder where the local copy of the wsdl is stored.
I checked whether that local folder actually contained the wsdl file - it did.
I tried editing the url in the jax-ws-catalog.xml file to point to port 8080 and 8081 - no joy.
I guess it is a security issue, but have no clue as to how to fix this.
Can anyone point me in the right direction here.
FYI: I'm fairly new to java and NetBeans.
Thanks.
The best way to avoid the error "Cannot find wsdl. Place the resource correctly in the classpath." is to use wsdllocation to specify the location of the wsdl and also to package the wsdl as part of the jar.
When you specify the wsdllocation make sure you add "/" to the beginning of the location.
wsimport -keep -Xnocompile -wsdllocation /schema/10.0/MyService.wsdl schema/10.0/MyService.wsdl
Just put your WSDL file in your classpath, etc., src/main/resources/MyWsdl.xml and use this to get it:
URL url = new URL(baseUrl, "classpath:MyWsdl.xml");
Also do not forget to add this on your service class that extends javax.xml.ws.Service:
#WebServiceClient(name = "MyService", targetNamespace = "http://example.org/", wsdlLocation = "classpath:MyWsdl.xml")
Not sure if this helps, but...
From Here
On the client side to consume SSL enabled Web service:
- in the New Web Service Client wizard under WSDL and Client location specify the WSDL file of the Web Service by setting WSDL URL in form
of https://:8181//
- then right click on the created web service and choose Edit Web Service Attributes and under Wsimport Options correct the wsdlLocation
option to the following form:
/META-INF/wsdl/_8181//.wsdl
Whenever you refresh the web service a fresh wsdl file gets loaded
from the deployed application and the wsdl file gets loaded as a
resource defined by the correct path (mentioned wsdlLocation option
value).
Make sure that you have configured your web service.
One way to do so is to implement a class that extends javax.ws.rs.core.Application. That is, add a class which is similar to the following:
import java.util.Set;
import javax.ws.rs.core.Application;
#javax.ws.rs.ApplicationPath("rest")
public class ApplicationConfig extends Application {
#Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new java.util.HashSet<Class<?>>();
addRestResourceClasses(resources);
return resources;
}
private void addRestResourceClasses(Set<Class<?>> resources) {
resources.add(rest.HelloWorld.class);
resources.add(rest.Search.class);
// Here continue adding all the JAX-RS classes that you have
}
}
I am new to web services and I have deployed a web service locally ( I am able to see the wsdl)
I tried to query the web service by creating a request in SOAPUI.
The response I got back was
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>java.lang.NoClassDefFoundError: org/apache/commons/lang/StringEscapeUtils
</faultstring>
</env:Fault>
I see a bunch of errors in the jboss console in eclipse...
11:53:06,226 ERROR [SOAPFaultHelperJAXWS]
SOAP requestexceptionjava.lang.RuntimeException:
java.lang.NoClassDefFoundError:org/apache/commons/lang/StringEscapeUtils
Can someone help me in figuring out what the problem could be?
Is something wrong with the way I setup my SOAPUI or is it I missed something in my project(web service server)
You need commons-lang.jar in your classpath
How do you exactly deploy the web service? For example, if you create an .aar archive, please verify that the corresponding jar (commons-lang.jar?) is available into the lib folder of the archive. For example:
your_service_root
->META-INF
->lib
->commons-lang.jar
-> com
->bla
->bla