Ajax calls web service. Web service returns string nodes and 1 node of binary data...How?

I've been all over the place looking for some helpful clues with ASP.Net 3.5 and handling binary data returned to a client.  Initially it was a standard PDF v1.3...at this point, I'd be happy to see that Ajax ASP.Net sending back an image or sound file embedded as binary data within the XML/SOAP data sent back to the user.  Below is one of several variations that I've tried.  Any suggestions?

1.  User clicks a button on the web page.  The button calls a JScript which calls the web service.

2.  The web service sends back an XML/SOAP response.  Some nodes contain text values.  The third node is supposed to contain binary data.  However, when the web service responds back to JScript I get an Internet Explorer Error of 'Null or Not An Object'.


Public Class PDFAjaxWebService
Inherits System.Web.Services.WebService
<WebMethod(EnableSession:=False)> _

Public Function ajaxPDFGenerator() As XMLPDFDataBlock
' Our custom-defined XML class
Dim xmlResponse As New XMLPDFDataBlock

 ' The location and filename where HTML code is located to have application translate into PDF format
Dim localTempLocation As String = "D:\testarea\files\temppdf.txt"

' Generate a binary data stream
Dim externalProcessPageVirtual As ProcessStartInfo = New ProcessStartInfo("htmldoc", "--quiet --webpage -t pdf " & localTempLocation)
externalProcessPageVirtual.RedirectStandardOutput = True ' Grab StdOut
externalProcessPageVirtual.RedirectStandardError = True ' Grab any errors (StdErr) that may come up if needed
externalProcessPageVirtual.CreateNoWindow = True ' No need to create a window for this operation
externalProcessPageVirtual.UseShellExecute = False ' We want the raw output
Dim runProcessPageVirtual As Process = Process.Start(externalProcessPageVirtual)

' Grab StdOut which is binary data
Dim generationResultsBinTemp As String = runProcessPageVirtual.StandardOutput.ReadToEnd()

' Build XML stream going back to the user
With xmlResponse
..generationResultsMsg = "Message 1" ' Text string being returned to client
..generationResultsURL = "Message 2" ' Text string being returned to client
..generationResultsBin = generationResultsBinTemp ' Binary data being returned to client...such as image, sound file, etc
End With
Return xmlResponse
End Function

End Class

' Define the return data going back to the JScript as a response
Public Class XMLPDFDataBlock

Private _generationResultsMsg As String
Private _generationResultsURL As String
Private _generationResultsBin As String

Public Property generationResultsBin() As String
Return _generationResultsBin
End Get
Set(ByVal value As String)
_generationResultsBin = value
End Set
End Property
Public Property generationResultsMsg() As String
Return _generationResultsMsg
End Get
Set(ByVal value As String)
_generationResultsMsg = value
End Set
End Property
Public Property generationResultsURL() As String
Return _generationResultsURL
End Get
Set(ByVal value As String)
_generationResultsURL = value
End Set
End Property

End Class
2/11/2008 11:14:37 PM
asp.net.networking-webservices 2181 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 23

The following link demonstrates how to chop up binary data into segments (that part is included to show how to send a parent node which has an infinite number of child nodes through a class declaration) and send back in XML/SOAP which is received by .Net Ajax/JScript.  In order to send back a large XML/SOAP message than the default size, which seems to be 60Kb, you will need to modify (on the server) the MaxRequestLength, etc.  The link also demonstrates how to work with a console application in a web service.

Try this URL: http://www.virtualsecrets.com/dotnet-35-web-services-ajax.html

2/19/2008 4:32:23 PM

Similar Artilces:

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Troubleshoot Web Service; Ajax AutoComplete events do not appear to not fire; Ajax web service appears to not work. .NET
Folks, I had the situation that Ajax AutoComplete events in the web service did not fire after I copied a project out of a folder, renamed it and moved it to a server. The fix was hard to find but easy to solve. I had some web service modules in an ASMX file that provided AutoComplete entries -- i.e., after the user keys in 2 or 3 characters, the list of possible entries with those leading characters is displayed for the user to select. To solve the problem, look at the web service's directive, not the code-behind or the ASMX designer.  Do a right-mouse-click...

Calling a Web Service from a Web Service
Hello,I was looking for some feedback on calling a web service from within a web service. I've heard that it's not good practice (or not possible). I have a scenario where I think it might make some sense.Within our infrastructure, we've created a web service that handles incoming updates on the statuses of all processes. This has proven to be a good thing since it allows applications to communicate across server to make status updates. It's also used by third party developers and applications to communicate with our infrastructure.Along these lines ... we are planning to create a new compon...

PB 11.5.1 (4011)
Hello Everyone, I am getting a strange error when calling a C# Web Service in PB 11.5.1 (4011). System.OutOfMemoryException When my application starts, I do the following: application global variable n_uploaded_files gnv_uploaded_files open event of application gnv_uploaded_files = CREATE n_uploaded_files n_uploaded_files instance variable s2010_upload_web_service iproxy_webservice SoapConnection iSOAP_connection constructor event of n_uploaded_files isoap_connection = CREATE SoapConnection of_instantiateservice(iproxy_webservice, "s201...

Can you call a web service from a web service?
I am trying to create a web service that itself consumes a 3rd party web service outside of our corporate firewall - so basically a web service consuming another web service.  I can consume this outside web service directly in an ASP.NET application without a problem.  But because the code is long and cumbersome, I wanted to provide our GUI developers an easy way to get all of the data they need from one source.  So I thought I could create an internal web service that would do a lot of things (query internal systems, for example) as well as consuming this external service.&nb...

web service call failed: 500 using ajax hovermenu and web service with ascx file
I am using a hovermenu extender on an image button. The hovemenu extender calls a web service and returns back information that I write to the panel that displays. A portion of the code is below. This works when the Page is an aspx page but when I move it to an ascx page I get web service call failed. I do have the ascx page in a folder called controls/pages off of the root but both the default.aspx page and the bedinfo.asmx page are on the root. I don't think I have a path problem. I can include more complete code, there are actually 50 images with 50 hovermenu extenders and one p...

'web service call failed: 500' using ajax hovermenu and web service
Hi there, I'm using a hovermenuextender attached to a templatefield of a gridview, and everything seemed to work fine.. however I've moved on to add dynamic attributes to the hovermenu. Now I get the error "web service call failed: 500" in place of the output I want (on the hovermenu's panel). When accessing the web service I created (directly through the browser) everything works fine.. here's my hovermenuextender dynamic attributes DynamicContextKey='<%=eval("refnumber") %>' DynamicServiceMethod="GetS...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="http://www.dynix.com/schema/book">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

Ajax call web services failed after convert web site into web project
Hi Guys I have one web site application and use ajax call web services. it is working very well. 1. Master page set up scriptmanager with webservices path. 2. Web service inside web site application under app_code named ajaxwebservice.cs 3. Javascript call ret=ajaxwebservice.method(id, oncomplete(),ontimeout(),onerror()); But after I convert web site into web application project, the ret=ajaxwebservice.method(id, oncomplete(),ontimeout(),onerror()); failed, the ajaxwebservice in undifined error. I use the same web.config, master page, I put my ajaxwebservice.asmx and ajaxwebservic...

Cannot call a web service from java script using ajax in .net 3.5 web applications
As like 2005 .net websites i tried to consume a web service from client side java script  using Ajax script manager in  .net 3.5 (2008) version web application it was not working, Event it works with 3.5 web sites, What i have to do to solve the issue. Thanks in advance Hi, can you create the least amount of code to reproduce it and post it? This gives us the ability to check out your code and better guide you. Also please check out this article: Create a Simple WCF Web Service and Use In JavaScript With Visual Studio 2008 and .Net 3.5.  Grz, Kris.Read my blog. Handy Fire...

DynamicPopulateExtender: Web Service call failed: 12152, Web Service call failed: 12031
Hi, I'm using a DynamicPopulateExtender to take the value of a SELECT dropdown and pass it to an onpage web service (defined with <System.Web.Services.WebMethod()> _ '<System.Web.Script.Services.ScriptMethod()>) and as PUBLIC SHARED FUNCTION myfunction(contextKey as string) as string. The function returns the html for a listbox. Everything seems to fire properly on the client but when the web service is called by the Javascript function, I get Web Service call failed: 12152 or Web Service call failed: 12031 Any pointers would be appreciated.  Do...

How i create web services & call web services?
Give me the solution of how i create webservices & call it and what is purpose of web services ?? PlsGuree  >how i create webservicesVery much the same as creating a new web site site - it is just a different project type. > & call it andAdd a web reference to an existing project to consume the web service.>what is purpose of web services ??To send and receive data.Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. &...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

Web resources about - Ajax calls web service. Web service returns string nodes and 1 node of binary data...How? - asp.net.networking-webservices

Public Broadcasting Service - Wikipedia, the free encyclopedia
... such as PBS NewsHour , Masterpiece , and Frontline . Since the mid-2000s, Roper polls commissioned by PBS have consistently placed the service ...

Australian public service allowances attacked: Institute of Public Affairs report
... and flex time under attack. The report by IPA deputy executive director James Paterson and lawyer Aaron Lane said federal public service wages ...

Leading autism service to be investigated over restraint policy
The Andrews government will order an independent review into the use of restraints by one of Australia's leading disability services in the aftermath ...

Melbourne heatwave: Emergency services on high alert as Victoria braces for season's worst fire weather ...
Authorities announce a total fire ban across Victoria on Saturday, as Melbourne experiences temperatures all over the place.

China Mobile creates dedicated unit to grow its internet services revenues
Zee News China Mobile creates dedicated unit to grow its internet services revenues Rethink Research (subscription) Many large mobile operators ...

The Beatles music reportedly coming to one streaming service on Christmas Eve
When Apple Music launched back in June, it was noted that the music subscription service didn’t offer up the entire iTunes catalog with a few ...

Target is taking on Apple Pay with its own mobile wallet service
... Of course, we’ll keep you posted with further information as we receive it. Target is taking on Apple Pay with its own mobile wallet service ...

LifeLock ID protection service to pay record $100 million for failing customers
... states. LifeLock was given a slap on the wrist and a $12 million fine in 2010 for falsely advertising its identity theft protection services. ...

Inside Apple’s plan to turn the iPhone into a subscription service
Apple is trying a new subscription service that would allow consumers to get an iPhone annually at no additional cost. At Business Insider's ...

Gillette Suing Dollar Shave Club Claiming Razor Subscription Service Infringes On Its Patents
... it’s no surprise that competition is fierce. In an effort to protect its slice of the market, Gillette is suing online subscription razor service ...

Resources last updated: 12/19/2015 5:11:57 PM