I am trying to call a web service from my SmartGWT program by coding on server side.
However the XMLTools.LoadWSDL(WSDLurl,WSDLLoadCallback) is giving me an error for the following code:
CODE :
XMLTools.loadWSDL("http://www.webservicex.net/uszip.asmx?WSDL",new WSDLLoadCallback(){
//#Override
public void execute(WebService webService) {
System.out.println("********************In XMLTools");
temp = webService;
}
});
ERROR :
java.lang.UnsatisfiedLinkError: com.smartgwt.client.data.XMLTools.loadWSDL(Ljava/lang/String;Lcom/smartgwt/client/data/WSDLLoadCallback;
What would be the cause and possible solution for the same?
Thanks!
Related
I am trying to compile the below piece of code to run a basic https server and i am encountering an error which i am not able to resolve. The class hello_world_resource is responsible for the server startup and the return statement gives the response that the server should give when it is accessed.
the url for the server is defined by function 'register_resource'
the url for the github documentation of the library - https://github.com/etr/libhttpserver
I've tried downloading ssl and curl multiple times and searched the google too but i am still not able to find the cause for this problem.
abcd.key and xyz.crt are the self-signed certificates that i generated following this procedure online -
https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04
#include <httpserver.hpp>
using namespace httpserver;
class hello_world_resource : public http_resource
{
public:
const std::shared_ptr<http_response> render(const http_request&)
{
return std::shared_ptr<http_response>(new
string_response("Hello, World!"));
}
};
int main()
{
webserver ws = create_webserver(8080)
.use_ssl()
.https_mem_key("/path/to/abcd.key")
.https_mem_cert("/path/to/xyz.crt");
hello_world_resource hwr;
ws.register_resource("/hello", &hwr);
ws.start(true);
return 0;
}
The error being thrown is :
terminate called after throwing an instance of 'std::invalid_argument'
what(): BD
A
(G BBJ
Aborted
the code should run and a server should be available at - https://localhost:8080/hello
i wanted to know what is the best approach to save WCF endpoints information in the config file for different environments(DEV,TEST,PRE-PROD, PROD).
i am familiar with 1 way of doing this - 1. Maintain different config files(for each env) and deploy them accordingly.
Can someone please suggest the best way to do this ??
You can configure the endpoint at runtime with endpointbehaviors. In this behaviors you can get the machinename for example. Depending on the machinename you could set yout endpointaddress for your endpoint, and then start the service.
Here is a link : https://msdn.microsoft.com/en-us/library/vstudio/ms730137%28v=vs.100%29.aspx
EDIT:
So you write:
class CustomEndpointBehavior : IEndpointBehavior{
public void Validate(ServiceEndpoint endpoint)
{
// get here the address and rewrite it dependig on the machinemane e.g.
// remember to set the new address to the endpoint!
}
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
}
}
And in the class where you start the service, you need to set the CustomEndpointBehavior to the serviceHost, like:
serviceHost.Description.Behaviors.Add(new CustomEndpointBehavior());
I think this is the link. Create multiple configuration and then use pre build event to copy it. http://www.hanselman.com/blog/ManagingMultipleConfigurationFileEnvironmentsWithPreBuildEvents.aspx
In you have visual studio 2010 and above then it will be able to merge the config. https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx
I have a problem when I am using the webservice from a mobile App Im developing in Flex Builder.
I have the following code for a Web service
<s:CallResponder id="readAllPedidosErpResult" result="readAllPedidosErpResult_resultHandler(event)" fault="sincFailResult_faultHandler(event)"/>
protected function readAllPedidosErp():void
{
readAllPedidosErpResult.token = xEasyERPMobileAppWS.readAllPedidosErp
(readFechaSincronizacionPedidoErp(),sC.readComercialUsuario());
}
protected function readAllPedidosErpResult_resultHandler(event:ResultEvent):void
{
var result:ArrayCollection;
var c:PedidoWSMobile;
if(event.token.result is ArrayCollection)
{
result = event.token.result as ArrayCollection;
if(result!=null)
{
//DO SOMETHING
}
}
continueToNext(15);
}
The problem I get is that xEasyERPMobileAppWS.readAllPedidosErp(readFechaSincronizacionPedidoErp(),sC.readComercialUsuario()); takes almost 2 minutes to get the answer but after 30 seconds (more or less) does not wait more and I got a fault (sincFailResult_faultHandler(event)).
How can I give more time to the CallResponder to wait the answer from the Web Service I am calling?
Thanks in advance.
I´ve just found the solution in another thread.
FYI: Adobe Flex 4.6 WebService request timeout
Thanks anyways!
The application I am working on calls many webservice. Just recently I have intergrated another web service that requires wsit-client.xml for Soap authentication.
That is working now but all the other SOAP services have stopped working.
Whenever any of them is being called, I see messages like
INFO: WSP5018: Loaded WSIT configuration from file: jar:file:/opt/atlasconf/atlas.20130307/bin/soap-sdd-1.0.0.jar!/META-INF/wsit-client.xml.
I suspect this is what is causing the Service calls to fail.
How can I cause the wsit-client.xml to be ignored for certain soap service calls?
Thanks
Fixed it by Using a Container and a Loader to configure a dynamic location for the wsit-client.xml. This way it is not automatically loaded. To do that, I first implemented a Container for the app as shown below
public class WsitClientConfigurationContainer extends Container {
private static final String CLIENT_CONFIG = "custom/location/wsit-client.xml";
private final ResourceLoader loader = new ResourceLoader() {
public URL getResource(String resource) {
return getClass().getClassLoader().getResource(CLIENT_CONFIG);
}
};
#Override
public <T> T getSPI(Class<T> spiType) {
if (spiType == ResourceLoader.class) {
return spiType.cast(loader);
}
return null;
}
}
Then to use it in the Code I do this
URL WSDL_LOCATION = this.getClass().getResource("/path/to/wsdl/mysvc.wsdl");
WSService.InitParams initParams = new WSService.InitParams();
initParams.setContainer(new WsitClientConfigurationContainer());
secGtwService = WSService.create(WSDL_LOCATION, SECGTWSERVICE_QNAME, initParams);
And it works like magic
I have a simple application with an web service created with Apache CXF. This application works when I run the server and the client (as Java applications). When I try to access the application /services URL which is mapped in web.xml, Tomcat gives me 404 error. When I run the project I receive:
org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {http://sendmessage/}SendMessage
If anyone has any hints related to this error I would be glad to hear them. (I searched google and couldn't find something relevant to my situation)
Thank you!
I had same error, mine was related to namespace which were different in wsdl and webservice. So I changed them to the same.
WSDL:
<wsdl:definitions name=""
targetNamespace="http://www.example.org/yourservice/"
Webservice class:
#WebService(targetNamespace = "http://www.example.org/yourservice/",
.........
Even I had a similar issue.
Fixed it by updating the jaxws:endpoint.
I added the serviceName (mapping to the name present in the WSDL file) with the name space as defined in the "targetNamespace" defined in the wsdl:definitions tag.
<jaxws:endpoint id=".." implementor="..." serviceName="s:SERVICE_NAME_IN_WSDL"
xmlns:s="TARGET_NAME_SPACE_WSDL_DEFINTIONS"></jaxws:endpoint>
edited(06Jul)
Also, I have today that, with Apache CXF 3.0.5 version this issue is not coming;
But with Apache CXF 3.1 version, this is coming.
ServiceConstructionException can occur at various stages when cxf compares the provided service, port and binding name with the wsdl it has already parsed. In this case ( and in most cases) it looks to be namespace issue.
{http://sendmessage/}SendMessage is either not present in parsed wsdl or the service name does not match with the QName present in the WSDL. There are other cases as well where binding or port does not match, one might receive the same exception. Following is a code snippit from org.apache.cxf.wsdl11.WSDLServiceFactory.create() method where it all happens.
If things are not clear why exactly it is happening your best bet is to debug this piece of code and see where it is failing and what is there in parsed wdsl definition (com.ibm.wsdl.DefinitionImpl in wsdl4j.jar).
javax.wsdl.Service wsdlService = definition.getService(serviceName);
if (wsdlService == null) {
if ((!PartialWSDLProcessor.isServiceExisted(definition, serviceName))
&& (!PartialWSDLProcessor.isBindingExisted(definition, serviceName))
&& (PartialWSDLProcessor.isPortTypeExisted(definition, serviceName))) {
try {
Map<QName, PortType> portTypes = CastUtils.cast(definition.getPortTypes());
String existPortName = null;
PortType portType = null;
for (QName existPortQName : portTypes.keySet()) {
existPortName = existPortQName.getLocalPart();
if (serviceName.getLocalPart().contains(existPortName)) {
portType = portTypes.get(existPortQName);
break;
}
}
WSDLFactory factory = WSDLFactory.newInstance();
ExtensionRegistry extReg = factory.newPopulatedExtensionRegistry();
Binding binding = PartialWSDLProcessor.doAppendBinding(definition,
existPortName, portType, extReg);
definition.addBinding(binding);
wsdlService = PartialWSDLProcessor.doAppendService(definition,
existPortName, extReg, binding);
definition.addService(wsdlService);
} catch (Exception e) {
throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
}
} else {
throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName));
}
PS: I know this issue was opened back in 2011 but recently I faced the same issue and was able to resolve it. I hope it help others who are facing this issue.
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for port {http://localhost:9990/project/wsdl/targetName}targetNameSoap12.
at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:179)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:428)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:548)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)
... 13 more
Fixed problem, define at annotation #WebService(targetNameSpace = "targetNameSoap12") in your web service interface and in the contract WSDL.
For exemplo:
...
<wsdl:service name='targetName'>
<wsdl:port binding='tns:targetNameSoap12' name='targetNameSoap12'>
...