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

  • SEARCH
  • Home
  • 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 6375423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:36:48+00:00 2026-05-25T01:36:48+00:00

I got a WCF service with a method to receive files, looking something like

  • 0

I got a WCF service with a method to receive files, looking something like this

public bool UploadFile(string fileName, byte[] data)
{
   //...
}

What I’d like to do is to post the data to this method in the WCF service from PHP, but are unaware if it’s even possible to post byte arrays from PHP to a .NET method hosted by a WCF service.

So I was thinking of something like this

$file = file_get_contents($_FILES['Filedata']['tmp_name']); // get the file content
$client = new SoapClient('http://localhost:8000/service?wsdl');

$params = array(
    'fileName' => 'whatever',
    'data' => $file 
);

$client->UploadFile($params);

Would this be possible or are there any general recommendations out there I should know about?

  • 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-05-25T01:36:50+00:00Added an answer on May 25, 2026 at 1:36 am

    Figured it out.
    The official php documentation tells that the file_get_contents returns the entire file as a string (http://php.net/manual/en/function.file-get-contents.php). What noone tells is that this string is compatible with the .NET bytearray when posted to a WCF service.

    See example below.

    $filename = $_FILES["file"]["name"];
    $byteArr = file_get_contents($_FILES['file']['tmp_name']);
    
    try {
        $wsdloptions = array(
            'soap_version' => constant('WSDL_SOAP_VERSION'),
            'exceptions' => constant('WSDL_EXCEPTIONS'),
            'trace' => constant('WSDL_TRACE')
        );
    
        $client = new SoapClient(constant('DEFAULT_WSDL'), $wsdloptions);
    
        $args = array(
            'file' => $filename,
            'data' => $byteArr
        );
    
    
        $uploadFile = $client->UploadFile($args)->UploadFileResult;
    
        if($uploadFile == 1)
        {
            echo "<h3>Success!</h3>";
            echo "<p>SharePoint received your file!</p>";
        } 
        else
        {
            echo "<h3>Darn!</h3>";
            echo "<p>SharePoint could not receive your file.</p>";
        }
    
    
    } catch (Exception $exc) {
        echo "<h3>Oh darn, something failed!</h3>";
        echo "<p>$exc->getTraceAsString()</p>";
    }
    

    Cheers!

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

Sidebar

Related Questions

Okay, I've got this WCF service going. It has a public access, which is
I got a WCF service that has simple method called GetLineBusses. public MobileResponse GetLineBusses(MobileRequest
I've got a WCF Web Service method whose prototype is: [OperationContract] Response<List<Customer>> GetCustomers(); When
I've got a WCF service with lots of method and DataContracts. It is usually
I've got a WCF service that offers a Login method. A client is required
I've got a WCF service which handles some sensitive data. I'd like to make
We've got the following WCF Service Contracts: [ServiceContract(Namespace = http://example.com, Name = Service1)] public
I've got an app which is using a WCF service. Now I'd like to
I've got a WCF service that will need to receive client credentials, and maintain
I've got an odata wcf service and it looks like InitializeService is not being

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.