I created a web service reference in my VS2010 project, and configured it with a WSDL service address URL. VS2010 created a nice proxy class for me to consume the web service.
I am getting a result that I don't like, and, in an effort to troubleshoot, I'd like to see the XML coming back from the web service. What is the simplest way to do so? I'd like to be able to do it within my Visual Studio debugging session, but if I have to go outside that, so be it.
I am trying to make the following work:
Dim response As HttpWebResponse = Nothing
Dim reader As System.IO.StreamReader = Nothing
Dim hwrResponse As HttpWebResponse = DirectCast(**request**.GetResponse(), HttpWebResponse)
Dim responseStream As System.IO.Stream = hwrResponse.GetResponseStream()
Dim xtrSmp As New System.Xml.XmlTextReader(responseStream)
Dim strXm As String = xtrSmp.ReadInnerXml()
xtrSmp.Close()
hwrResponse.Close()
but I don't know what my request should be.
Your REQUEST should be a REQUEST Object whiich is configured to access the SOAP service you are trying to access...
You can find out more here...
HTTPWEBRESPONSE object http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.aspx
HTTPWEBREQUEST object http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx
Use one of theseWebServiceStudio (http://webservicestudio.codeplex.com/),
Storm (http://storm.codeplex.com/)
or the outstanding Eclipse WSDL Editor and Web Service Explorer (look at http://wiki.eclipse.org/index.php/Introduction_to_the_WSDL_Editor)
These will let you invoke your service methods with an ad-hoc GUI client generated from WSDL and access both request and response XML.
The list of tools above is of course incomplete.
Related
I have only an array of byte on the client side.
Another server send me JSON
{
report - byte[]
}
I am looking for ways to save byte [] in browser
Send them to server or I can download from client side.
I can not find any solution at all.
So my question "Is it possible to save with restygwt byte [] an how???"
It is not possible to save the file directly from Resty.
https://github.com/resty-gwt/resty-gwt/issues/341
The most common workarounds to download files using AJAX are not using AJAX at all.
You can simply change the URL (using window.location) or (using javascript) create or;
create a form (using JS) and post that form.
In my projects, I simple create a URL to my REST endpoint attaching any query parameters needed and use it as the href to a link.
For instance, if your RestyGwt endpoint points to /entity/1/bytes
just do
new Anchor("Download", "/entity/1/bytes");
your endpoint must produce a downloadable file type say:
#Produces("text/txt")
I am calling a REST based service API from a ASP.NET 4.0 Webforms application.
The REST service requires HTTP Basic Auth and this has worked just fine so far. I'm using this code snippet to define my credentials for my HttpWebRequest object (serviceUsername, serviceUserPassword and serviceUrl are strings being passed in):
NetworkCredential credentials = new NetworkCredential(serviceUsername, serviceUserPassword);
HttpWebRequest httpReq = WebRequest.Create(serviceUrl) as HttpWebRequest;
httpReq.Credentials = credentials;
httpReq.Method = "GET";
httpReq.Accept = "application/json";
and then I fire off my request.
Today, suddenly, for one customer, things went haywire. Nothing seemed to work anymore - all my calls were rejected with a HTTP 401 - Unauthorized - even though, using the same URL and credentials, I was able to call this REST API from Fiddler.
The ultimate reason was a £ character in the password......
So Fiddler seems to have handled that gracefully, somehow - while ASP.NET falls flat on its nose. What extra step do I need to do in order for ASP.NET 4.0 to also work gracefully even if my customer decides to put a pound symbol in their (probably machine-generated) password? Any tricks or way to handle this?
I am trying to create a few restful webservices that will add a bit functionality to the company cisco phones. The basic idea is simple, the users get a small client on which they need to enter login and password. When they have done so, their phone/phones are 'registered' to my restful service and they get added functions on their phone. When they log out, they get unregistered. To provide the extra functions (like adjusted caller information etc etc) I need the Cisco AXL API. This is a SOAP based API. I have generated the java classes using the wsdl already. When I make a testclient using the generated classes, all works fine.
But here comes the problem: When I try to run a soap request while my application is deployed on my Tomcat 7 container, it doesn't work anymore.
The problem seems to be the AXLAPIService, which hangs when executing the following piece of code:
#WebEndpoint(name = "AXLPort")
public AXLPort getAXLPort() {
return super.getPort(new QName("http://www.cisco.com/AXLAPIService/", "AXLPort"), AXLPort.class);
}
In other words, i am not getting a port for the soap request and it makes the tomcat crash i f you wait long enough.
I went googling. Somebody on some forum once had a problem because of an out of date stax version. I adjusted the stax version in my POM and tried again, to no help.
I also read somewhere that the underlaying javax.xml.ws.Service actually has an enumeration of ports, and when you do getPort(), you will get the most appropiate port. I then looked up the default port for SOAP and that would be 80, just like the port used for RESTful services. Could it be that the soap service would be wanting port 80, but that it can't have it because it is already in use?
So, to summarize my question:
can it be that my restful services consume the same port that my soap
request would want to use?
if not, what could be the problem then and how should I fix it?
As additional information, this is how the axl wsdl defines the service:
<service name="AXLAPIService">
<port binding="s0:AXLAPIBinding" name="AXLPort">
<soap:address location="https://CCMSERVERNAME:8443/axl/"/>
</port>
I was thinking about changing the soap port myself. Some googling tells me I should do that in the wsdl but I wouldn't really know how. There is post already here but I fail to see how binding another portname could help me out....
As with so many things involving Cisco Telephony and their Administrative XmL (AXL), I found a workaround instead of an actual answer. Since a problem never really leaves my mind, I spent the rest of yesterday trying to find a solution for getting information out of that AXL thing.
Any actual answers to the above questions are still welcome though.
The workaround I found is this: Since SOAP can be seen as a special http POST request, it should be possible to do a SOAP call using a REST framework such as Jersey. You just need some extra code to make it work. I used the 'SoapProvider' from the link and for those who are also wrestling with this, I'll add my code:
public void doSoapRequest() throws SOAPException, JAXBException{
ClientConfig config = new DefaultClientConfig();
config.getClasses().add(SoapProvider.class);
Client c = Client.create(config);
c.addFilter(new LoggingFilter());
c.addFilter(new HTTPBasicAuthFilter("user", "password"));
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPElement bodyElement = body.addChildElement(envelope.createName("getCCMVersion", "", "http://www.cisco.com/AXL/API/8.5"));
message.saveChanges();
WebResource service = c.resource("https://youraxlmachine:8443/axl/");
// POST the request
ClientResponse cr = service.type(MediaType.TEXT_XML).header("SOAPAction", "\"https://youraxlmachine:8443/axl/getCCMVersion\"").post(ClientResponse.class, message);
message = cr.getEntity(SOAPMessage.class);
JAXBContext ctx = JAXBContext.newInstance(GetCCMVersionRes.class);
Unmarshaller um = ctx.createUnmarshaller();
GetCCMVersionRes response = (um.unmarshal(message.getSOAPPart().getEnvelope().getBody().extractContentAsDocument(), GetCCMVersionRes.class)).getValue();
System.out.println("HERE COMES THE VERSION!");
System.out.println(response.getReturn().getComponentVersion().getVersion());
}
I have left as many things unchanged as I could, except for the company specific details. This code works for getting the CCM version.
WARNING: Depending on how you perform the request, you might get a different result for the same request. I'll explain:
I have implemented other AXL methods as well, such as getUser. Before I even coding the Jersey soap service, I tried everything with SOAPUI. So I setup the SOAPUI so I could do RESTful requests to the AXL server. Using my restful setup in SOAPUI, I get the same results as I when would do the standard SOAP calls using both SOAPUI and my first implementation of a soapclient in java.
But when I use the jersey client to do the same getUser request, some important fields are missing from the result. I have no clue what could have caused this. For the request getPhone, I dont even get a valid response. So be warned.
I am trying to hit the alfresco rest api using my standalone rest code. i get the login ticket when i use the below url -
"http://host:port/alfresco/service/api/login?u=admin&pw=admin"
and i got the ticket but how do i use this ticket for further communication with alfresco without facing this authentication problem.
below is the code i am using for communicating with the alfresco rest client.
HttpGet getReq = new HttpGet(url);
getReq.addHeader("accept", "application/json");
StringEntity input = new StringEntity(args);
HttpResponse response = client.execute(getReq);
Kind Regards
Garvit Jain
Append the alf_ticket argument to your URL and pass in the ticket you retrieved from the /api/login call. See http://wiki.alfresco.com/wiki/Web_Scripts#Authenticating
How can I had soap AUTH BASIC auth to a WSDL, so who ever reads the WSDL knows I require that operation for a specific method ?
Using the example bellow I have managed to pass the SOAP basic autentication to the php webservice on the other end.
The PHP.net/Soapclient has a simple working example, but in csharp I found this link to be a solution to my problem.
link
Michaelis.MockService is the Webservice library extracted you may see an example on how to do this in:
link Mono project website.
Michaelis.MockService service = new Michaelis.MockService();
// Create the network credentials and assign
// them to the service credentials
NetworkCredential netCredential = new NetworkCredential(“Inigo.Montoya”, “Ykmfptd”);
Uri uri = new Uri(service.Url);
ICredentials credentials = netCredential.GetCredential(uri, “Basic”);
service.Credentials = credentials;
// Be sure to set PreAuthenticate to true or else
// authentication will not be sent.
service.PreAuthenticate = true;
// Make the web service call.
service.Method();
There is no way to specify this, as far as I know.