Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all 555 articles
Browse latest View live

Unable to import binding '...cfcSoapBinding' from namespace 'http://...'.

$
0
0

I've been given the URI of a WSDL file, but when I try to add a reference to it, Visual Studio complains about a number of things.

The error message in VS is the subject line above, while in the body of the file, these 2 lines have blue squiggly lines beneath them:

<xsd:import namespace="http://xml.apache.org/xml-soap" />             "imported schema for namespace http://xml.apache.org/xml-soap was not resolved"

<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> "imported schema for namespace http://schemas.xmlsoap.org/soap/encoding was not resolved"

Still learning about web services and I can't seem to find any useful info about resolving these errors.

Any suggestions greatly appreciated.

David

 


Soap Header WCF

$
0
0

Hi, i have a service in which SOAP Header Attribute is used for passing paramters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "S:Apple.Summry")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]

public class Service : System.Web.Services.WebService
{
    public class Apple : SoapHeader
    {
        public string Amountt = "0.0";
        public string Number = "1";
        public string Type = "Credit";
        public string Date = "2011/09/26";
        public string Id = "AVST000XXXX201109990000012";
    }
	
    public Service () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
    public Apple apple;

    [WebMethod]
    [SoapHeader("apple", Direction = SoapHeaderDirection.InOut)]
    public void HelloWorld() 
    {
        if (apple == null) { apple = new Apple(); }
    }
}



but now i need do this work in a wcf service

Please help how do i use Soap Header in WCF, its really urgent please help me......

wcf endpoint - address attribute usage?

$
0
0

Hello - an endpoint has abc attributes: address, binding, contract. However, I've written WCF services with an address attribute value of "" and I'm able add the service reference to a client and call the endpoint without issue.

It appears that the client app will auto-populate the endpoint address attribute value based on the url that's provided when adding the service reference to the client app.  So is the address attribute really only needed in order to provide a logical relative endpoint address when defining multiple endpoints for a service? 

search design with wcf rest services?

$
0
0

What are your thoughts on the proper design of a WCF REST service that performs a search?  Search functionality is essentially a GET, meaning its goal is to get data from the server - not to set data.

However, search criteria can sometimes be complex - for example a user might want to search on 3 different search criteria. If a client needs the ability to perform a combination search on 3 different search criteria then a message request structure seems like the best solution to encapsulate this request.

However, GET doesn't support request messages meaning a POST would be needed to process a message request structure.  So how do you normally go about implementing a REST web service for a complex search? Do you use a POST and send the criteria as a request message (which seems to violate REST prinicples) or do you use a GET and use some other method to pass the criteria (which seems like a possible kludge)?

only 1 service endpoint getting auto-added to client app

$
0
0

Hello - I've created a WCF service and I've defined 2 endpoints for the service in the service app:

<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
     <endpoint name="webHttp" address="webHttp" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web"></endpoint>
     <endpoint name="wsHttp" address="wsHttp" binding="wsHttpBinding" contract="RestService.IRestServiceImpl"></endpoint>
</service>

However, when I update my service reference in my console app only the endpoint named "wsHttp" gets added to the client section in the app.config of my console app. The endpoint named "webHttp" is not getting added. Is there a reason why the "webHttp" endpoint isn't getting automatically added to the client section of my app.config?

Reading the value from ArrayOf_xsd_string - From a Java Webservice

$
0
0

Hi,

Am facing an error while consuming a java web service. In WSDL data type for the parmeter is given as

- <complexType name="ArrayOf_xsd_string">
- <sequence>
  <element maxOccurs="unbounded" minOccurs="0" name="item" type="xsd:string" />
  </sequence>
</complexType>
 
While debugging values are just showing string[0] for the paramer with dataype string[]. How to read this value?.
 
Thanks

500 System.ServiceModel.ServiceActivationException for an Ajax call to WCF rest service

$
0
0

Ajax Call:

   $.ajax({
        type
: "POST",
        url
: "http://SomeService/ServiceName.svc/GetSearchResults",
        data
: JSON.stringify({ parameters: serviceParameters }),
        contentType
: "application/json; charset=utf-8",
        dataType
: "XML",
        success
: function (response) {
            $
("#xmlText").text(response.xml);
       
},
        error
: function (msg) {
            alert
(msg.toString);
       
}
   
})

WCF Interface:

[OperationContract]
       
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Json,
                   
UriTemplate = "GetSearchResults")]
       
XElement GetSearchResults(inputParameters parameters);

       
[OperationContract]
       
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate = "getFile")]
       
Stream GetFile(DocInfo info);

Web.config:

 <system.web>
   
<compilation debug="true" targetFramework="4.0" />
   
<customErrors mode="Off"/>
 
</system.web>

 
<system.webServer>
   
<modules runAllManagedModulesForAllRequests="true"/>
 
</system.webServer>

 
<system.serviceModel>
   
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
   
</serviceHostingEnvironment>
   
<standardEndpoints>
     
<webHttpEndpoint>
       
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
     
</webHttpEndpoint>
   
</standardEndpoints>
 
</system.serviceModel>

The service is hosted on IIS6.

When I call the service I get the following error message:

500 System.ServiceModel.ServiceActivationException

I can call the GetFile method and get the response stream but I get the error message when calling GetSearchResults.

Any help will be appreciated.


wcf mutliple svc endpoints example?

$
0
0

Hello - What are some real-world examples where you would need to create a WCF service with multiple endpoints?  Also, can a client choose the service endpoint to use simply by passing the endpoint name as a constructor argument to the service client proxy class or is anything else required for this?


gzip compression on WCF in shared hosting

$
0
0

Hi.

I have a WCF rest service and it is hosted on a shared hosting (discountasp).

I want to compress the responses. Since it is hosted on  a shared hosting, I dont have access on IIS.

I have tried many things with no luck.

Can anybody plz help me in this regard ??

Getting The remote server returned an error: (500) Internal Server Error

$
0
0

I have written below code to send the SOAP XML request

XmlDocument objSoapXML = new XmlDocument();

objSoapXML.LoadXml(sSoapXML);

HttpWebRequest objHttpWebRequest = (HttpWebRequest)WebRequest.Create(productURL);

objHttpWebRequest.ContentType = "text/xml;charset=\"utf-8\"";

objHttpWebRequest.Accept ="text/xml";

objHttpWebRequest.Method ="POST";

using (Stream objReqStream = objHttpWebRequest.GetRequestStream())

{

objSoapXML.Save(objReqStream);

}

// begin async call to web request.

IAsyncResult objAsyncResult = objHttpWebRequest.BeginGetResponse(null, null);

objAsyncResult.AsyncWaitHandle.WaitOne();

string soapXMLResult;

// get the response from the completed web request

using (WebResponse objWebResponse = objHttpWebRequest.EndGetResponse(objAsyncResult))

using (StreamReader objSteamReader = new StreamReader(objWebResponse.GetResponseStream())){

soapXMLResult = objSteamReader.ReadToEnd();}

 When posting request for above service URL it is throwing "The remote server returned an error (500) internal server error". For the same URL from same machine it works fine from SOAPUI application. I could get successful response but above .NET code doesn't work. So what could be the issue. Any help will be apperciated.

Using WCFtestClient.exe to test webservice

$
0
0

HI Im currently Using WCFtestClient.exe to test my webservice and it gives me the following error

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.


i read online that we should update the buffer size in the client config file but how can i do that with WCFtestclient.exe

WebService doesn't do any changes when i modify it

$
0
0

hii , i'm working with visual studio 2010 with asp.net/c#  and i have a web application with webservice.

the problem is that i have to do a little changes in my Webservice.asmx.cs, but when i modify something nothing happen

it seems like i didn´t change anything, i think it is because the webservice is already published in a server or something like that but i don´t know much about those things..

does anybody have any idea what could i do?? thanks

problem installing/using x509 certificate

$
0
0

Hello - I used makecert to generate a temporary x509 certificate using the following command:

makecert -n "CN=RootCATest" -r -sv RootCATest.pvk RootCATest.cer

When I double-click the certificate that was generated, an "Install Certificate..." button is displayed at the bottom of the General tab.  When I click the "Install Certificate" button the system leads me through a Certificate Import Wizard. I select all the defaults including "Automatically select the certificate store based on the type of certificate".

At the end of this process the Certificate Import Wizard displays an alert "The import was successful."  However, if I double-click on the certificate again the top of the General tab still says "Certificate Information - This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authorities store."

The subject of the certificate is RootCATest. Here is the serviceCertificate from my service web.config:

<serviceCertificate findValue="RootCATest" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />

When I try to update the service reference from my consol app the system returns the following error:

"Cannot find the x.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue 'RootCATest'."

What am I missing here?

certificate working with clientCredentialType="Windows" but not "UserName"

$
0
0

Hello - I have a serviceCertificate configured for my WCF service. I'm able to successfully update the service reference from my console app with the following configuration:

<wsHttpBinding>
<binding>
<security mode="Message">
<message clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>

However, the system returns an error when I try to update the service reference from my console app with the following configuration:

<wsHttpBinding>
<binding>
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>

The error returned is:  "It is likely that the certificate 'CN=RootCATest' may not have a private key that is capable of key exchange or the process may not have access rights for the private key."  Any idea why I get this error for clientCredentialType "UserName" but not "Windows"?  Does clientCredentialType "Windows" not use the certificate?

Communicate between web services

$
0
0

i have a  WCF  web service that communicate with database directly. 

i need to add another WCF web service in the middle between the original web service and the database.

how i can do that? what is the needed configurations to do that?


How to set the parameter of a child node in c#

$
0
0

Hi guys,

I have a ASMX webservice that I need to call with no form or anything that has this following structure

<soap:Body><Purchase xmlns=""><po><UserName>string</UserName><Password>string</Password><Status>string</Status><POnumber>string</POnumber><feature1>string</feature1><feature2>string</feature2><linesIN><partNumberIN><InternalSku>string</InternalSku><HardwareNumber>string</HardwareNumber><opt1>string</opt1><opt2>string</opt2></partNumberIN><partNumberIN><InternalSku>string</InternalSku><HardwareNumber>string</HardwareNumber><opt1>string</opt1><opt2>string</opt2></partNumberIN></linesIN></po></Purchase>

I have mapped this webservice via servicereference in visualstudio and have managed to call the other functions but I havent worked
with this for a couple years and kinda forgot how to do it. I seem to get everything right except that the InternalSku is not passed and is null. 

public void orderRequest() {

ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);

V31sandbox.GEN_WS_SAND_Ver3_1SoapClient CallWebService = new V31sandbox.GEN_WS_SAND_Ver3_1SoapClient();
V31sandbox.PURCHASE PCH = new V31sandbox.PURCHASE();
V31sandbox.partNumberIN PNI = new V31sandbox.partNumberIN();
PCH.UserName = sxID;
PCH.Password = sxPWD;
PCH.POnumber = OrderNumber;
PNI.InternalSku = InternalSKU;

V31sandbox.PURCHASE_RESPONSE PUR = new V31sandbox.PURCHASE_RESPONSE();
PUR = CallWebService.Purchase(PCH);

What am I doing wrong here?

Im guessing I have to Tie the PNI togher with PNI with the PCH or just write it in a different way but how do I do that?  The other fields in partNumberIn are optional so I dont have to pass those.

Any help is Appreciated. 

Error: The SOAP action specified on the message, '', does not match the HTTP SOAP Action

WCF app

$
0
0

I am looking for some help with the following application I am new to WPF and WCF so any resources or code will be helpful

Create a sample WPF Application (using the MVVM design pattern) with a grid that shows and updates data.

 The WPF Application will show data in a DevExpress Grid (A free trial and sample source code from here https://www.devexpress.com/Products/NET/Controls/WPF/demos.xml).

The data will be consumed via a WCF Service call initiated by a button or on the open of the application – the DevExpress Grid will also allow editing on the row update.

The WCF Service will also expose Insert /Update/Delete service calls that will take the edited/inserted values and send them back to the data store updating/inserting the data.

The data source can be SQL Server, XML, a text file, or another source.

Need to deploy ASP.NET Web Services in IIS in windows 10

$
0
0

HI, 

It been 2 days i am trying to deploy a web service in IIS on windows 10.  My requirements was to call the web service from Javascript in another domain so i need to use JSONP. I downloaded a sample code from internet and then completed by development with Web Services running in one Visual Studio development environment and web application in another.  I am using Visual Studio 2015 and the web service project i downloaded, i open it as web project and it work OK.   one thing that was in the web services as a special Module class that was needed to make sure that JSONP is working when a call comes in. 

Now i want to configure it in IIS on windows 10. I did the simple steps and created a website and point it to my directory.   Now my javascript code in web site cannot make connection with web service running in IIS

I suspect this is something to do with Module that handles JSONP.      I am dying now to get it working by tomorrow so a immediate help will be highly appreciated. 

Here is my web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings />
<connectionStrings />
<system.web>

<compilation debug="true" defaultLanguage="c#">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>

</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5" />
<providerOption name="WarnAsError" value="false" />
</compiler>
</compilers>
</system.codedom>

<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ScriptModule" />
<add name="JSONPModule" type="JsonpHttpModule, App_Code" />
</modules>
<handlers>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</handlers>
</system.webServer>
</configuration>

Here is my IHTTPHandler code file and my web service had only one web method 

using System;
using System.Web;
using System.IO;
using System.Text;

public class JsonpHttpModule : IHttpModule
{
private const string JSON_CONTENT_TYPE = "application/json; charset=utf-8";

#region IHttpModule Members
public void Dispose()
{
}

public void Init(HttpApplication app)
{
app.BeginRequest += OnBeginRequest;
app.ReleaseRequestState += OnReleaseRequestState;
}
#endregion

bool _Apply(HttpRequest request)
{
if (!request.Url.AbsolutePath.Contains(".asmx")) return false;
if ("json" != request.QueryString.Get("format")) return false;
return true;
}

public void OnBeginRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;

if (!_Apply(app.Context.Request)) return;

if (string.IsNullOrEmpty(app.Context.Request.ContentType))
{
app.Context.Request.ContentType = JSON_CONTENT_TYPE;
}
}

public void OnReleaseRequestState(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;

if (!_Apply(app.Context.Request)) return;

app.Context.Response.Filter = new JsonResponseFilter(app.Context.Response.Filter, app.Context);
}
}

public class JsonResponseFilter : Stream
{
private readonly Stream _responseStream;
private HttpContext _context;

public JsonResponseFilter(Stream responseStream, HttpContext context)
{
_responseStream = responseStream;
_context = context;
}

public override bool CanRead { get { return true; } }

public override bool CanSeek { get { return true; } }

public override bool CanWrite { get { return true; } }

public override long Length { get { return 0; } }

public override long Position { get; set; }

public override void Write(byte[] buffer, int offset, int count)
{
var b1 = Encoding.UTF8.GetBytes(_context.Request.Params["callback"] + "(");
_responseStream.Write(b1, 0, b1.Length);
_responseStream.Write(buffer, offset, count);
var b2 = Encoding.UTF8.GetBytes(");");
_responseStream.Write(b2, 0, b2.Length);
}


public override void Close()
{
_responseStream.Close();
}

public override void Flush()
{
_responseStream.Flush();
}

public override long Seek(long offset, SeekOrigin origin)
{
return _responseStream.Seek(offset, origin);
}

public override void SetLength(long length)
{
_responseStream.SetLength(length);
}

public override int Read(byte[] buffer, int offset, int count)
{
return _responseStream.Read(buffer, offset, count);
}
}

Shahzad

      

C# XML Element Prefix SOAP

$
0
0

I have seen many SO answers but non seem to help with the issue I have. What I am doing is calling a SOAP service from third party and it actually requires a prefix on element names. Example:

<pref:test>test</pref:test>

I have created a client using Add service reference in VS. I have a class which is where i want the prefix on each property.

public class WebsiteSoapHeader : System.Web.Services.Protocols.SoapHeader
	{
		public WebsiteSoapHeader()
		{
			xmlns.Add("test", "https://xxx/service");
		}

		[XmlNamespaceDeclarations]
		public XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces();
		[XmlElement(ElementName ="test",Namespace = "https://xxx/service")]
		public string testprop { get; set; }
	}

As this does not get serialized manually it only produces

<test xmlns="">test</test>

Viewing all 555 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>