Call Web Service using wget - web-services

I'm able to call a web service from Linux command line using CURL.
Now I'm tryng to use wget to call a Web Service but I always receive the following error:
500 Internal Server Error.
I'm using the following syntax:
wget http://<endPoint> --post-file=soapRequest.xml --header="Content-Type: application/soap+xml" --output-document=soapResponse.xml
Where soapRequest.xml contains the XML request (validated by SoapUI).
The error returned from wget is:
Connecting to <host:port>... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2011-12-12 23:18:33 ERROR 500: Internal Server Error.

You don't mention which webserver you are using, or how your URL is formatted, but to invoke a web service operation written in .NET on IIS use this syntax:
wget --post-file=soaprequest.xml --header="Content-Type: text/xml" --header="SOAPAction: \"soapaction\"" http://server/app/myservice.asmx -O response.xml
The "soapaction" value can be found in the WSDL, or on the information page ASP.NET creates for the operation at myservice.asmx.

I have to use --header="Content-Type: text/xml"

Related

Unable to link dialogflow webhook to ngrok tunnel

Have created a chatbot and I am trying to connect it to my local host using ngrok....the localjost is running via my computer and is showing active...however dialogflow webhook is not able to send any request to the ngrok portal...
I have tried multiple time to host a server via ngrok and pasted the link in webhook section in Dialogflow..but dialogflow diagnostic shows
Webhook call failed. Error: PERMISSION_DENIED.
fulfillment status ngrok cmd prompt ngrok server
Any help would be appreciated...not sure what I am missing....
Without seeing the actual configuration, there are a few things I would look at:
Make sure you're actually using the right ngrok URL from your console. Many times I was using an older URL in the Dialogflow configuration.
Make sure you're using the HTTPS URL.
Make sure your server is actually running on your computer, and that it is listening at the same port that ngrok is using on your computer.
Check the ngrok console to see if it is getting the request at all and what the response might be.
Go to http://localhost:4040/ which will give you details of each connection through ngrok.

timeout in retrieving the WSO2EI service wsdl from php on pass through transport

After installing WSO2EI-6.1.1 to migrate from my old WSO2DSS to EI, I was trying to setup a simple php wsdl soup client to call the "Version" service from php with a direct link to service wsdl and I'm getting the following error:
php code:
try {
$client = new SoapClient("http://server-ip:8280/services/Version?wsdl");
$response = $client->getVersion();
var_dump($response);
} catch (SoapFault $fault) {
echo $fault->getMessage();
}
error:
Fatal error: Maximum execution time of 120 seconds exceeded
Seems like the connection is timing out... I have tried to get the service wsdl with file_get_contents with the same result, timing out. well sometimes it works with a terrible loading time of like 90-100 seconds, but most of the times it times out.
$wsdl = file_get_contents("http://server-ip:8280/services/Version?wsdl");
var_dump($wsdl);
I have tested the link in browser and it is loading fine. Also tested with curl from linux command line and it loads fine there as well so the link is accessible.
curl -v http://server-ip:8280/services/Version?wsdl
So the timeout happens only when I try to retrieve the wsdl from within php. however if I download and save the wsdl file and pass the local xml file in php instead, then the service works fine and the version is fetched and displayed.
try {
$client = new SoapClient("Version.xml");
$response = $client->getVersion();
var_dump($response);
} catch (SoapFault $fault) {
echo $fault->getMessage();
}
So it seems like the problem is only fetching the wsdl directly from server in php and the rest of the communication between the server and the client is working fine.
after few hours searching I decided to try nhttp transport in transportReceiver configuration of axis2 instead of pass through transport and the problem is solved. however, reading the docs it is noted that the default transport is pass through and it is better in terms of performance compared to nhttp.
so is it a bug or something there causing the problem or am I doing something wrong and its possible to retrieve the wsdl directly from server within php while using the pass through transport?
Update:
when I use port numbers 9763 for http or 9443 for https instead of 8280 and 8243 to access services or service wsdl then I can access services or wsdl from php with no problems. So can anyone please explain to me whats the difference when using the port number 9763 or 8280 to access a service over http transport? Is it ok to use 9763 instead of 8280 to deal with services or to use 9443 instead of 8243? Is it still using the passthru transport when I use ports 9763 and 9443?
All WSO2 servers have two types of transports — servlet and passthrough (or nhttp). These are used for different purposes. Servlet transports are exposed over port 9443 and 9763 by default. This is the port used by admin services and the management console. The version service also uses the same port. For the services that you write and deploy, they are exposed over 8280 and 8243 ports. To answer your question, for this service you have to use 9763 or 9443 ports. And you will be accessing the Version service over servlet transport and not passthrough transport.

django rest api curl giving notification gateway timeout

When running the curl on rest api :
curl -X POST -H "Authorization: Token <token_id>" "http://localhost:4000/api/.....url"
I am getting
The system cannot communicate with the external server The Internet server may be busy, may be permanently down, or may be unreachable because of network problems.Please check the spelling of the Internet address entered.If it is correct, try this request later.If you have questions, please contact your organization's network administrator and provide the codes shown below.
Username:my username
Source IP: my ip
URL: POST http://localhost/api/.....url
Category:
Reason: UNKNOWN
Notification: GATEWAY_TIMEOUT
as the response. It was working properly earlier. Can you tell me what is wrong.
I made the server run in localhost:4000 and gave it on curl but the response in giving gateway timeout.
btw im under proxy.

Wcf web service

I have a WCF web servive which I have hosted on same network PC(not where client application run). When I try to add service reference to client application the following error is raised...
Note: I can access the web service through web browser where client application runs
Microsoft Visual Studio
There was an error downloading 'ipaddress/uploads/TransferService.svc/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: [/ipaddress/uploads/TransferService.svc].
Content Type application/soap+xml; charset=utf-8 was not supported by service ipaddress/uploads/TransferService.svc. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not supported by service
ipaddress/uploads/TransferService.svc. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
Anyone please help in this??
If your target framework is 4.5 or higher, you can try to download service as a single WSDL — just append ?singleWSDL to the URI when requesting metadata from the service.

How to run an ssl EJB Webservice?

I have created an Ejb endpoint WebService (.EAR) using metro and glassfish 3.1.2(b5) .
The wsdl file is published and accessible via https .
I generated the client artifact from the secured url and when I Run the client I get this error (server side):
ATTENTION: Invalid request scheme for Endpoint my_web_service. Expected https . Received http
This how I configured the secure connexion:
<glassfish-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>my_web_service</ejb-name>
<webservice-endpoint>
<port-component-name>my_web_service</port-component-name>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</webservice-endpoint>
</ejb>
</enterprise-beans>
</glassfish-ejb-jar>
If I change the implementation to a servlet endpoint (.war) everything run ok so I think that I'm missing something in the configuration.
To make this work you need to update the bundled version of grizzly in glassfish to 1.9.55 .