Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:33:05+00:00 2026-06-07T07:33:05+00:00

I need to send an image to a SOAP web service implemented in PHP.

  • 0

I need to send an image to a SOAP web service implemented in PHP.

The WSDL for the service looks like this…

<xsd:complexType name="Product">
  <xsd:all>
    <xsd:element name="ProductId" type="xsd:int"/>   
    <xsd:element name="Image01" type="xsd:base64Array"/>
  </xsd:all>
</xsd:complexType>

When I reference this service in my C# application the data type used for Image01 is String.

How can I get an image from disk and send encode it in the correct way to send it via this complex type?

Would appreciate sample code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:33:08+00:00Added an answer on June 7, 2026 at 7:33 am

    Load the image up into a byte[] type then run it through a Convert.ToBase64String()

    There’s a nice sample of code on this question to load a file from disk into a byte[]

    public byte[] StreamToByteArray(string fileName)
    {
    byte[] total_stream = new byte[0];
    using (Stream input = File.Open(fileName, FileMode.Open, FileAccess.Read))
    {
        byte[] stream_array = new byte[0];
        // Setup whatever read size you want (small here for testing)
        byte[] buffer = new byte[32];// * 1024];
        int read = 0;
    
        while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
        {
            stream_array = new byte[total_stream.Length + read];
            total_stream.CopyTo(stream_array, 0);
            Array.Copy(buffer, 0, stream_array, total_stream.Length, read);
            total_stream = stream_array;
        }
    }
    return total_stream;
    }
    

    So you’d just do

    Convert.ToBase64String(this.StreamToByteArray("Filename"));
    

    And pass that back via the web service call. I’ve avoided using the Image.FromFile call so you can re-use this example with other non image calls to send binary information over a webservice. But if you wish to only ever use an Image then substitute this block of code for an Image.FromFile() command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want send an image from my App to web service, to do it,
I need to send an image (as a downloadable file) from an ASP web
I need to Send Image from silverlight to WCF service. I try to do
I need to show image(thumbnail) in view page using controller/action.(like: /Image/Thumbnail) I can send
I am writing an web application where I need to send an image from
I need to send out an email with multiple image attachments from PHP. I
I have a slow connection that I need to send a PNG image over
I need send certain attributes(say, human readable user name) from server to client after
I need to send instant messages (like forum PMs) between users with my asp.net
I need to send large amounts of data (image files) by POST in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.