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 7736895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:51:33+00:00 2026-06-01T07:51:33+00:00

I’m currently exploring powershell capabilities, but I have encountered a problem that I have

  • 0

I’m currently exploring powershell capabilities, but I have encountered a problem that I have not been able to solve. Any quick tips would be greatly appreciated =)

My goal:
Invoke methods from a WCF service (configured with MTOM message encoding) from powershell v2.0 (hopefully using the new-webserviceproxy cmdlet)

My problem:
the new-webserviceproxy cmdlet cannot parse the service’s response correctly when message encoding is set to Mtom. I receive the following error:

PowerShell:


$proxyObject = New-WebServiceProxy -URI "http://myserver.com/AccessService.svc?wsdl"
$proxyObject.TestWebServiceConnection()

Exception calling “TestWebServiceConnection” with “0” argument(s): “Client found response content type of ‘multipart/related; type=”application/xop+xml”;start=”&lthttp://tempuri.org/0&gt”;boundary=”uuid:

4001d529-32b9-4560-9f4b-550c35c67b03+id=4″;start-info=”text/xml”‘, but expected ‘text/xml’.

The request failed with the error message:

—

–uuid:4001d529-32b9-4560-9f4b-550c35c67b03+id=4

Content-ID: &lthttp://tempuri.org/0&gt

Content-Transfer-Encoding: 8bit

Content-Type: application/xop+xml;charset=utf-8;type=”text/xml”

&lts:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope/”&gt

&lts:Body&gt

&ltTestWebServiceConnectionResponse xmlns=”http://myserver.com/”&gt

&ltTestWebServiceConnectionResult&gtsuccess&lt/TestWebServiceConnectionResult&gt

&lt/TestWebServiceConnectionResponse&gt

&lt/s:Body&gt

&lt/s:Envelope&gt

–uuid:4001d529-32b9-4560-9f4b-550c35c67b03+id=4–

–.”

At line:1 char:38

+ $proxyObject.TestWebServiceConnection &lt&lt&lt&lt () &gt&gt error.txt

+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException

+ FullyQualifiedErrorId : DotNetMethodException

Note I am able to consume the WCF service through other clients and even the wcfclient tool provided by Microsoft. You can see that the TestWebServiceConnectionResult returned success, but it doesn’t seem like the proxy object was able to parse the response.

Behavior:

&ltserviceBehaviors&gt

&ltbehavior name=”MyServiceBehavior”&gt

&ltserviceThrottling maxConcurrentCalls=”100″ maxConcurrentSessions=”100″/&gt

&ltserviceMetadata httpGetEnabled=”true” httpsGetEnabled=”false”/&gt

&ltserviceDebug includeExceptionDetailInFaults=”false”/&gt

&lt/behavior&gt

&lt/serviceBehaviors&gt

Binding(I’ve excluded the timeout values/ reader quota and message sizes since the permutations of their values do seem not relevant to my problem):

&ltbasicHttpBinding&gt

&ltbinding name=”basicHttpEndpointBinding” messageEncoding=”Mtom”&gt

&ltsecurity mode=”None”&gt

&lttransport clientCredentialType=”None”/&gt

&lt/security&gt

&lt/basicHttpBinding&gt

Service

&ltservice behaviorConfiguration=”MyServiceBehavior” name=”MyService.AccessService”&gt

&ltendpoint address=”” binding=”basicHttpBinding” bindingConfiguration=”basicHttpEndpointBinding” name=”basicHttpEndpointAccessService” bindingNamespace=”http://myserver.com/” contract=”MyService.IAccessService”/&gt

&ltendpoint address=”mex” binding=”basicHttpBinding” bindingConfiguration=”basicHttpEndpointBinding” name=”mexEndpointAccess” contract=”IMetadataExchange”/&gt

&lt/service&gt

  • 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-01T07:51:34+00:00Added an answer on June 1, 2026 at 7:51 am

    As of the time of this writing, I still have not been able to successfully use the New-WebServiceProxy cmdlet with a WCF service with MTOM enabled; it does not look like the cmdlet supports it. My workaround involved running svcutil.exe against the wsdl, and then compiling the class into a dll using csc.exe. I then loaded the generated assembly into the powershell run time, and then configured the endpoint and binding of the proxy class manually:

    Generating the .cs file from your wsdl:

    $svcUri = "http://yourdomain/yourService.svc?wsdl";
    $csFile = $className + '.cs';   # The name of the generated .cs file
    $dllName = [System.IO.Path]::Combine($temp, $className + ".dll")
    $svcUtilresult = svcutil.exe /noConfig /out:$csFile $svcUri
    

    Note svcutil.exe and csc.exe may not be in your powershell’s PATH. You can either add it to your PATH or use the full path. Svcutil can be found within your Microsoft SDKs\Windows\<version>\bin. csc.exe is located in your %windir%Microsoft .Net folder

    Once you have generated the .cs file, you will need to compile it into a dll:

    &"csc.exe" /t:library /out:$dllName $csFile
    

    Load the compiled dll into powershell:

    $fileStream = ([System.IO.FileInfo] (Get-Item ".\$dllName")).OpenRead()
    $dllBytes = new-object byte[] $fileStream.Length
    $fileStream.Read($dllBytes, 0, $fileStream.Length)
    $fileStream.Close()
    
    [System.Reflection.Assembly]::Load($dllBytes)
    

    Instantiate the proxy client in powershell:

    # Load System.ServiceModel, which can be found in your Framework\v3.0\Windows Communication Foundation folder
    [System.Reflection.Assembly]::LoadFile($pathToSystemServiceModel)
    
    # className is the name of your service
    $serviceClientName = $className + "Client"
    
    $basicHttpBinding = New-Object System.ServiceModel.BasicHttpBinding
    $basicHttpBinding.MessageEncoding = [System.ServiceModel.WSMessageEncoding]::Mtom
    
    $endPoint = New-Object System.ServiceModel.EndpointAddress($svcUri)
    $wsClient = New-Object $serviceClientname($basicHttpBinding, $endPoint)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.