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

How to fix "Namespace prefix 'soap' not defined" ? (use WSE 2.0 SP3 [.NET Framewok 1.1])

$
0
0

Hi all,

I use WSE 2.0 SP3 (.NET Framewok 1.1) for consume secure web service.

But I try to send the UsernameToken with SOAP Header to the secure web service.

See below,

....

UsernameToken userToken = new UsernameToken(userName,password, PasswordOption.SendPlainText);
SoapContext requestContext = this.objProxyService.RequestSoapContext;
requestContext.Security.Tokens.Add(userToken);
MessageSignature sig = new MessageSignature(userToken);
requestContext.Security.Elements.Add(sig);

......

this.objProxyService.GetValue();  --> Error Appear

But the error is occurred, "Namespace prefix 'soap' not defined".

Does it have problem from the SOAP Message use "soapenv" prefix?

Below is expect SOAP message

<soapenv:Envelope xmlns:ser="http://servicexxxxxxxxxx.xx.xx" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header>
    <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <wsse:UsernameToken wsu:Id="UsernameToken-448969DA1257B4367F14967409135479">
        <wsse:Username>MyUsername</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">MyPassword</wsse:Password>
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">dnvHwbnDwj27eNtJhTPpAw==</wsse:Nonce>
        <wsu:Created>2017-06-06T09:21:53.547Z</wsu:Created>
      </wsse:UsernameToken>
    </wsse:Security>
  </soapenv:Header>

........

How can I solve this problem?

Thank you very much,


How to consume JSON in C#.Net WebService

$
0
0

I need to write C#.Net web service that will consume/call JSON service exposed methods So

  • How can i make proxy classes from JSON?
  • How can i consume a JSON web service methods in C#.Net application.
  • How the message will send/receive?
  • How will i transform JSON message in .NET

Please advise me to remove "wsu:Timestamp" in SOAP Header. (WSE 2.0 for Framework 1.1)

$
0
0

Hi all,

I use WSE 2.0 for Framework 1.1 to add UsernameToken to SOAP Header.

I have a problem about SOAP Header. I try to use customer myclass (inherites from "SoapOutputFilter" class) to remove "//wsse:Security/wsu:Timestamp".

public override void ProcessMessage(SoapEnvelope envelope)
{
            //removing Addressing headers from the outgoing request
            XmlNode securityNode = envelope.Header["//wsse:Security/wsu:Timestamp"];
            envelope.Header.RemoveChild(securityNode);
 }

but the error "Object Reference not set" is occurred.

Please advice me, how can I remove "wsu:Timestamp" node in SOAP Header?

Thank you very much

Smile

The type or namespace name 'Services' does not exist in the namespace

$
0
0

Hi All,

I have hosted a web application which uses webservices, which were created by me.

All was working fine, no issues at all.

But suddenly what is happened, it started showing error. "The type or namespace name 'Services' does not exist in the namespace"

I did not make any changes to application, application pool in IIS not even in a single file of the application. So why this is happening.

Even I try to add reference of System.Data.Service but not working.

See the image below

How to handle Json resull with null

$
0
0

hi, new to Json. I m a newbie on Json REST.

1) here the Json result :

{
  "Status": 0,
  "AlertCode": 0,
  "Message": null,
  "Results": {
    "Case_ID": 543061,
    "Case_Ref_Num": "100549642",
    "Case_Caller_Info": "Customer ABC",
    "Case_Caller_Tel": null,
    "Case_Caller_Company": " Customer ABC"
  }
}

2) using Json2csharp to generate the classes for the above json result:

public class Results
{
    public int Case_ID { get; set; }
    public string Case_Ref_Num { get; set; }
    public string Case_Caller_Info { get; set; }
    public object Case_Caller_Tel { get; set; }
    public string Case_Caller_Company { get; set; }
}

public class RootObject
{
    public int Status { get; set; }
    public int AlertCode { get; set; }
    public object Message { get; set; }
    public Results Results { get; set; }
}

I would like to know how to handle the null like   "Message": null

How to loop thru the Json Result?

Thanks

ASMX web service deployment issue

$
0
0

I developed web service in asmx under 4.5 framework. it's working perfectly but facing issues while dumping data into database from webservice. I deployed my web service on IIS server. It is consuming through this server  but when web service reached to dump data in database then web service execute without any exception but data not dump in database. Is there IIS server configuration issue. Dot Net Framework 3.5  not add in my feature list. when i tried to add role and feaure of framework 3.5 this error occured "Do you need to specify an alternate source path? One or more installation selections are missing source files on the destination server. The server will try to get missing source files from Windows Update, or from a location that is specified by Group Policy. You can also click the “Specify an alternate source path” link to provide a valid location for the source files"  Is Framework 3.5 cause dump issue in Database through my web service. your valuable answer will be helpful for me. 

Make a web service request and read response from example cUrl

$
0
0

Hi,

I have an below example of cURL command, i want to make a similar webservice request using .NET Can someone please help me convert below curl to .NET request.

Thanks in advance.

curl-H'X-API-TOKEN: yourapitoken'-H"Expects:" \-F'surveyId=SV_012345678912345' \-F'file=@example.csv;type=text/csv' \'https://yourdatacenterid.qualtrics.com/API/v3/responseimports'

.NET Webservice - Performance testing

$
0
0

Hi,

I am working on a .NET web service. It is deployed on IIS 7.5 (Web server is Windows 2008 R2, 64 bit machine, 8 GB RAM) and it is used to send and receive data between client application and web server.

I would like to check the performance of the web service if more people are accessing at the same time. Kindly suggest some ways to simulate the number of users accessing the web service at the same time and track the performance. I would like to know how many users the web service can handle at the same time.

Thanks Ashok


convert Node.JS webservice call to C#

$
0
0

Hi Folks,

I have an Node.JS script which is making a webservice call the script works great , i am looking to convert this Node.JS script to C# webservice call.

Can someone please help. Thanks in advance.

var request = require('request');
var fs = require('fs');
var url = "https://yoururl/API/v3/responseimports";
var surveyId = "SV_ePswPpv4rPD77fL";
var token="AXXXXXXXXXXXXXZZZZ";
var formData={
	surveyId:surveyId,
	file: fs.createReadStream("test.csv")
};

var options = {
	headers:{
		'content-type':'multipart/form-data',
		'X-API-TOKEN':token
	},
	method:"POST",
	url:url,
	formData: formData
};

request(options, function(error,response,body){
	if(error){
		console.log("Error" +error);
	}
	else{
		console.log(response.body);
		console.log("webservice call completed");
		console.log(response.statusCode);

	}

});

StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers

$
0
0

I am using ASP.NET MVC4 and calling a method within a controller from one MVC4 project to another, using PostAsync.  I am not using any authentication attribute within the called controller or method.

Referencing this link: [link][1]   [1]: https://stackoverflow.com/questions/16573145/asp-net-mvc-4-401-access-deniedhttp://

Fixed my issue when running application locally and calling PostAsync to application on server. Now, when I deploy the application to the server and try to call the other application I get the unauthorized error. What am I doing wrong?

Both application running in IIS are using the same site, and the same application pool.

Using remote debugging, this is the server response:

    {StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:     {       Cache-Control: private       Server: Microsoft-IIS/7.0       WWW-Authenticate: Negotiate       WWW-Authenticate: NTLM       X-Powered-By: ASP.NET       Date: Fri, 23 Jun 2017 13:44:19 GMT       Content-Length: 6644       Content-Type: text/html; charset=utf-8     }}

And this is my code:

using (var handler = new HttpClientHandler { UseDefaultCredentials = true })
using (HttpClient client = new HttpClient(handler) { BaseAddress = new Uri(Properties.Settings.Default.EnvironmentRootPath)})
{
  List<string> orderNumbers = NumList;
   var pairs = new List<KeyValuePair<string, string>>
   {
     new KeyValuePair<string, string>("orderNumbers", string.Join(",", orderNumbers))                 };
     var content = new FormUrlEncodedContent(pairs);
     var response = client.PostAsync("CentralBroadcast/broadcastNewOrder", content).Result;

if (response.IsSuccessStatusCode)
{                     //
}
else
{                     //
}

Application Pool is using Network for Identity.

Read large binary file into byte array - File.ReadAllBytes throws 'System.OutOfMemoryException'

$
0
0

Running on Windows Server 2003, IIS 6.0, Visual Studio 2010, .Net Framework 3.5

The web service is throwing a "System.OutOfMemoryException" whenever it tries to read a file large binary file (> 80 Meg).

To make troubleshooting this issue easier, I have separated out the code into a simple web service with only one call
GetByteArrayFromFile which reads a file and returns a byte array.

It consistently throws the 'Out of Memory' exception with files larger than 80 Meg.

Are there any steps I can take to resolve this issue?

'**********************************************************
'Web Service Call
Imports System.Web.Services, System.Web.Services.Protocols, System.ComponentModel

<System.Web.Services.WebService(Description:="Testing", _    
  Namespace:="http://Testing.org/")> _
  <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
  <ToolboxItem(False)> _
Public Class ProcSvcs   Inherits System.Web.Services.WebService

<WebMethod(Description:="Byte array from File")> _  
Public Function GetByteArrayFromFile(ByVal PathFName As String) As Byte()    
Try      
  Dim Content() As Byte = System.IO.File.ReadAllBytes(path:=PathFName)      
  Return Content    
Catch ex As Exception      
   Throw New Exception(ex.Message)    
End Try  
End Function

End Class

 

Web service in web application

$
0
0

Suppose i have given source code of particular web application.

How can i know which web services are used in that application?

Where to search for used web services?

How to know all the methods and parameters for those web services?

Exposing a webservice

$
0
0

What is exposing a webservice?

---------

My scenario,

We have a webapplication in which we are using a webservice created by us.

If i want some third person to use that webservice, what exactly i need to do?

Do i need to expose that webservice and give that link to that person? I want that person to see all function definitions in that webservice so which arguments to pass to each function and all.

So that person can use it. 

Thank you.

Hosting a Web Service in IIS

$
0
0

Hi there,

            I have created a Web Service using ASP.Net and its working fine. Now i need to Host this service on IIS, to get accessed in my Local Network.

I tried to host the Service in IIS and when i tried to Browse the Site from IIS its working fine but when i am trying to Consume the service from other application its giving me Error.

"Service Not Found".

Service URl = http://localhost:8006/MySqlService.asmx?WSDL

Can you please suggest me how to host a web service, so that it can be accessed from all the PC's in my network.

Thanks

Regards

 

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].

$
0
0

Hi..

  I have created web service using net.tcp and I'm getting the following when I try to host the service.

 "Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http]."

  I have tried activating nonhttp, tcp listener adapter and tcp sharing is active in services.msc. Please help.

Thanks,


Basic Authentication from SOAPUi into WCF

$
0
0

I am trying to switch the default WCF service ( Service1) with the endpoints GetData(int) & GetDataUsingDataContract(compositeType) from operating anonymously to accepting basic authentication, cong from SOAPUI

The SOAPUI request looks like

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1234D5C071B185E32DA799996999339999">
<wsse:Username>TestID</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">TestPass</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">aa9GNM4983dxaPGU90i+SA==</wsse:Nonce>
<wsu:Created>2017-07-10T15:18:53.202Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<tem:GetData>
<tem:value>3</tem:value>
</tem:GetData>
</soapenv:Body>
</soapenv:Envelope>


I have tweaked the web config to look like this, as this is what I believed was required for Basic Auth

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.serviceModel>
<diagnostics>
<endToEndTracing activityTracing="true" />
</diagnostics>
<bindings>
<wsHttpBinding>
<binding name="UsernameWithTransport">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="BasicAuthentication.Service1">
<endpoint address="http://localhost:1234/Service1.svc"
binding="wsHttpBinding"
bindingConfiguration="UsernameWithTransport"
name="BasicEndpoint"
contract="BasicAuthentication.IService1" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>

To provide addtional information in the debugger, I have added the code

var Appcontext= OperationContext.Current;

to retrieve all the information about how visual studio thinks the app is being run. Numerous objects inside Appconect show that it is being run anonymously  (IsAuthenticated is  false , Principal Name is empty etc.) 

The app goes on to return the value "You entered 3", back to SOAPUI

I can confirm that when I start this in IIS Manager local,  the Website Authentication settings have Anonymous Authentication DISABLED  and Forms Authentication ENABLED

How do I make my WCF Service accept the values in the header for Username & password should be treated as an attempt to login? 

Response Status code 400:Bad Request because of posting data with large size (httpclient)

$
0
0

at my project (asp.net soap webservice) I'm sending a form contains a file and a string to a webservice method via httpclient right as below:

using(FileStream fs =File.Open(FileFullPath,FileMode.Open,FileAccess.Read,FileShare.ReadWrite)){using(var client =newHttpClient(newHttpClientHandler{UseProxy=false,Proxy=null})){using(var formData =newMultipartFormDataContent()){
                    client.Timeout=TimeSpan.FromMilliseconds(Timeout.Infinite);//client.MaxResponseContentBufferSize = fs.Length;HttpContentTokenContent=newStringContent(Token);HttpContent fileStreamContent =newStreamContent(fs);

                    formData.Add(TokenContent,"Token");
                    formData.Add(fileStreamContent,Key, currentFile);var response = await client.PostAsync(WebServiceOfServer, formData).ConfigureAwait(false);// equivalent of pressing the submit button on the formif(!response.IsSuccessStatusCode){
                        result =null;}else{
                        result = response.Content.ReadAsStreamAsync().Result;returntrue;}}}}

But in sending files which have the size grearter than 2GB, the response status code is 400 with the BadRequest phrase reason. 
 And In the web.config I used this codes:

<httpRuntimemaxRequestLength="3145728"requestLengthDiskThreshold="3145728"targetFramework="4.5.1"requestValidationMode="2.0"executionTimeout="999999"/>

and

<requestLimitsmaxAllowedContentLength="3221225472"/>

How can I solve my problem?

 

 

Using WCF with real time XML exchange

$
0
0
Hi everyone,

I'm new to WCF I would like to understand the approach or workaround with the requirement below.

My company has multiple applications in .Net window form. All the are done by vendor where code change is not allowed. The application will generate the XML files in FTP Folder where current exchange by using ETL.

ETL unable to archive real time file exchange. Could I use the WCF to archive the exchange data requirement in real time? The data will be load from one end in XML and WCF service shall transform the data that fit the data format for another end by transmitting the transformed file in XML to receiver's folder. The receiver will pick up the XML thereafter to its database.

Thanks for any advice

Unalbe to create java script proxy file for WCF service on server.

$
0
0

Hi,

I have created AJAX enables WCF service and want to consume it through javascript. In local Visual Studio everyting is working fine but when I host that application in the server, service is not able to call.

One thing I notice is that through server I am not able to get js proxy file which we get by typing serviveName/js in the url.

I am getting HTTP 404 error on that. Can anyone please suggest.

New in WCF

$
0
0

Getting this error at the time of compiling WCF service:

"Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata."

The service encountered an error:

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: http://tempuri.org/:ITIN_EXT_ServiceMobile ----> ..... bla, bla....

My service is:

namespace MyService
{
    using TIN.DataMobile;       

    [ServiceContract]
    public interface ITIN_EXT_ServiceMobile
    {
        [OperationContract]
        string findContact(int eid);

        [OperationContract]
        String addUser(string uID);

        [OperationContract]
        Mob_AddSessionOut Mob_AddSession(Mob_AddSessionIn pInput);
    }
}

The issue is in the last service because all is fine with the first two service.

Where:

public class Mob_AddSessionOut
    {
        public String Auth_token { get; set; }
        public Boolean Transaction_moviment { get; set; }
        public TIN.DataAccessLayer.Gen_StatusProcess StatusProcess { get; set; }    

    }

What am I doing wrong?

Thanks

Viewing all 555 articles
Browse latest View live


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