Could not find definition for webservice at wildfly 9 - web-services

I wrote a webservice and the building Maven is all ok, but the deployment on wildfly 9 receives error:
Could not find definition for service {http://ws.sieciowyandroid.rogal.com/soap/Map}MapService.
all log server: here
wsdl is: here
and schema: here
and my code:
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
#WebService(name = "MapWebServiceEJB", targetNamespace = "http://ws.sieciowyandroid.rogal.com/soap/Map",
serviceName = "MapService", portName = "MapPort", wsdlLocation = "wsdl/api.wsdl")
public class MapWebService implements MapPort {
#Override
public GetThumbnailResp getThumbnail(#WebParam(partName = "in0", name = "GetThumbnailReq", targetNamespace = "http://ws.sieciowyandroid.rogal.com/soap/GetThumbnail") GetThumbnailReq in0) {
GetThumbnailResp response = new GetThumbnailResp();
try {
response.setResult("czesc "+ in0.getName());
} catch (Exception e) {
response.setResult("ERROR");
}
return response;
}
}
I did not notice a fault that could cause this exception.
I will be grateful for your help

This may or may not be related, but if you are using Maven to package the dependencies, then you may be stripping out the schema file mappings. I had a similar problem with Spring Framework and the answer posted here solve my problem. You can likely replace the spring references with the appropriate resources for your issue.
Idea to avoid that spring.handlers/spring.schemas get overwritten when merging multiple spring dependencies in a single jar

Related

API Manager error creating SOAP API: (Double Gateway)

We are using API Manager 2.1.0 with a distributed deployment (double gateways).
When we create a SOAP API using a soap endpoint, we get an error.
These are the steps we followed in the API creator web interface:
Create a new API 'I Have SOAP endpoint'
In the Design API we add all the information required and save
When saving, we have an error when importing the WSDL:
ERROR {org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader} - Error occurred while getting the wsdl address location {org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader}
java.net.MalformedURLException: no protocol: null/testphone/1.0
at java.net.URL.<init>(URL.java:593)
at java.net.URL.<init>(URL.java:490)
at java.net.URL.<init>(URL.java:439)
at org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader.setServiceDefinition(APIMWSDLReader.java:307)
at org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader.updateWSDL(APIMWSDLReader.java:156)
at org.wso2.carbon.apimgt.impl.utils.APIUtil.createWSDL(APIUtil.java:1375)
at org.wso2.carbon.apimgt.impl.APIProviderImpl.updateWsdl(APIProviderImpl.java:731)
at org.wso2.carbon.apimgt.impl.APIProviderImpl.updateAPI(APIProviderImpl.java:836)
at org.wso2.carbon.apimgt.impl.UserAwareAPIProvider.manageAPI(UserAwareAPIProvider.java:72)
at org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject.saveAPI(APIProviderHostObject.java:1061)
at org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject.jsFunction_updateAPIImplementation(APIProviderHostObject.java:672)
at sun.reflect.GeneratedMethodAccessor392.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
and the WSDL imported (in the registry) has a null in the location in wsdl:port.
If we use only one gateway and import the same WSDL we do not have the error and everything works smoothly.
The problem is not related to the WSDL and it happens with all WSDL.
How can we solve it?
We have solved the problem. These are the steps we used following this link (https://wso2.org/jira/browse/APIMANAGER-5843) and (https://github.com/wso2/carbon-apimgt/pull/4301/commits/c9d38bd0864bc84b3d8f5731ccc6a49068448f33):
Download the source code of the version of your API Carbon Mgt and locate APIUtil.java (org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/utils/APIUtil.java)
Find the method getGatewayendpoint(String transports) and replace it with this code lines:
public static String getGatewayendpoint(String transports) {
String gatewayURLs;
Map<String, Environment> gatewayEnvironments = ServiceReferenceHolder.getInstance()
.getAPIManagerConfigurationService()
.getAPIManagerConfiguration()
.getApiGatewayEnvironments();
if (gatewayEnvironments.size() > 1) {
for (Environment environment : gatewayEnvironments.values()) {
if (APIConstants.GATEWAY_ENV_TYPE_HYBRID.equals(environment.getType())) {
gatewayURLs = environment.getApiGatewayEndpoint(); // This might have http,https
// pick correct endpoint
return APIUtil.extractHTTPSEndpoint(gatewayURLs, transports);
}
}
for (Environment environment : gatewayEnvironments.values()) {
if (APIConstants.GATEWAY_ENV_TYPE_PRODUCTION.equals(environment.getType())) {
gatewayURLs = environment.getApiGatewayEndpoint(); // This might have http,https
// pick correct endpoint
return APIUtil.extractHTTPSEndpoint(gatewayURLs, transports);
}
}
for (Environment environment : gatewayEnvironments.values()) {
if (APIConstants.GATEWAY_ENV_TYPE_SANDBOX.equals(environment.getType())) {
gatewayURLs = environment.getApiGatewayEndpoint(); // This might have http,https
// pick correct endpoint
return APIUtil.extractHTTPSEndpoint(gatewayURLs, transports);
}
}
} else {
gatewayURLs = ((Environment) gatewayEnvironments.values().toArray()[0]).getApiGatewayEndpoint();
return extractHTTPSEndpoint(gatewayURLs, transports);
}
return null;
}
Locate org.wso2.carbon.apimgt.impl_6.1.66 and replace the class with the new APIUtil.java
Add this patch according to WSO2 documentation
Now you can publish on mutliple gateway

How to write unit test for WEB API Http Method and Custom Route

I need to write unit test for, 1) web api method has [HTTPPOST] method type and 2) web api method has route attribute [api/Verification].
Can any one suggest, how to write test to do this.
I found one of the way for web api route verification using http://www.vannevel.net/2015/03/08/50/ but RouteAssert is not found.
I am writing unit test using MSTest.
Tried below way to find descriptor so, can check for route and httpmethods, problem is, its giving null for methodInfo.
private HttpActionDescriptor GetAction(AccountAPIController controller, string name)
{
try
{
MethodInfo methodInfo = controller.GetType().GetMethod(name, new Type[] { controller.GetType(), controller.GetType() });
return new ReflectedHttpActionDescriptor { MethodInfo = methodInfo, Configuration = controller.Configuration, ControllerDescriptor = new HttpControllerDescriptor()};
}
catch (Exception ex)
{
throw;
}
}
I found the solution by reflection to verify for class and method attributes. It works finally.
Thanks.

simple azure web service, http404 error on publish when adding /dowork to URL

I am trying my first web app service using Azure services. I've created it in VS, and it works locally. All it does it return a string that says "hello user" is JSON.
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1
{
// To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
// To create an operation that returns XML,
// add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
// and include the following line in the operation body:
// WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
[OperationContract]
[WebGet(UriTemplate = "/DoWork")]
public string DoWork()
{
// Add your operation implementation here
return "hello user";
}
// Add more operations here and mark them with [OperationContract]
}
}
Problem is when I publish it, says successful. I can see it running on portal.
When I goto published site I get the standard THIS WEB APP HAS BEEN SUCCESSFULLY CREATED, but... when I add the /DoWork to the URL I get HTTP error 404.
I know I must be missing something simple...
any ideas?
you're missing the name of the service. In your case would be something like:
http://engineappservicev001.azurewebsites.net/something.svc/dowork
More info in here:
http://www.codeproject.com/Articles/571813/A-Beginners-Tutorial-on-Creating-WCF-REST-Services

calling web service from login module n websphere

I have a websphere login module which calls a web service to get some information while authenticating. There is a different web service URL for different environments. Can anyone suggest the best way of deploying this so I dont have to redeploy the code between environments.
I have added the wsdl's to the META-INF folder in my deployed jar file. And set custom properties for the login module so I can determine which wsdl file to get.
However when I search for the wsdl it does not correctly load it as it throws a null pointer after intialisation.
[6/26/14 15:23:48:786 BST] 00000048 SystemOut O Debug: com.xxx.login.module.xxxCustomLoginModule
[6/26/14 15:23:48:786 BST] 00000048 SystemOut O got wsdl Url file:/usr/websphere7/ndb70SU3_B
117/lib/ext/xxxCustomLoginModule.jar!/META-INF/wsdl/my-pre.wsdl
the code I use to load it is the same as in the geenrated files
MYWS adamStub = null;
debugOut("WebserviceUrl = " +this.options.get("webServiceWsdlLocation"));
if(this.options.get("webServiceWsdlLocation") != null) {
URL wsdlUrl = getWsdlUrl();
debugOut("got wsdl Url " + wsdlUrl.getPath());
new MYWS (wsdlUrl, new QName(QNAME_WEBSERVICES, IADAM_L));
} else {
adamStub = new MYWS ();
}
and the get wsdl method
private URL getWsdlUrl() {
URL wsdlUrl = null;
try {
wsdlUrl = adam.xxxxxxx.class.getResource(
(String)this.options.get("webServiceWsdlLocation"));
if(wsdlUrl == null)
throw new MalformedURLException((String)this.options.get("webServiceWsdlLocation")+
" does not exist in the module.");
} catch(MalformedURLException e) {
e.printStackTrace();
}
return wsdlUrl;
}
I thought that this would have been the best way to do it for different environments but it cant seem to load the wsdl correctly. The get wsdl code is taken directly from the generated class and the line below works fine
adamStub = new MYWS ();
All suggestions are appreciated. I dont want to regenerate the client for each environment or from my build.
UPDATE:
Made a proper schoolboy error here forgot to do the assignment
new MYWS (wsdlUrl, new QName(QNAME_WEBSERVICES, IADAM_L));

Creating client for web service

I have deployed a simple hello service in jboss server. I can view the wsdl file. Can someone help me with the client side. I mean how to access this service? Is there any way to access from web browser? Method deployed is
#WebMethod
public String greet( #WebParam(name = "name")
String name )
{
return "Hello" + name;
}
Try to know what is the wsdl url to access the service which you have just exposed. It might most probably be something like "http://localhost: < port-number >/ems-ejb/?wsdl"
If you type the same in the browser, you should be able to see the wsdl file (page with full of xml tags).
Once done, follow the steps provided here
Example on how to call the method once client stub is generated
String endpoint = "your wsdl url";
GreetImplServiceLocator objGreetImplServiceLocator = new GreetImplServiceLocator();
java.net.URL url = new java.net.URL(endpoint);
GreetIntf objGreetIntf = objGreetImplServiceLocator.getFaultImplPort(url);
String greetings=objFaultIntf.greet("stackoverflow");