bonjour,
j'utilise un web service pour me creer des fichier sur le disk (ou sur le serveur) .
sauf que quand je passe par le silverlight il le repond pas et le webs ervice ne cree pas les fichier .
mais quand je le test sans le silverlight ca fonctionne .
voici mon code du silverlight :
voici le code de mon web service:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 BinaryWriter bwOutput=null; Stream aud = _sink.BackingStream; // nouveau bwOutput.Write("RIFF".ToCharArray()); // Total Length Of Package To Follow // Computed as data length plus the header length without the data // we have written so far and this data (44 - 4 ("RIFF") - 4 (this data)) bwOutput.Write((uint)(aud.Length + 36)); bwOutput.Write("WAVE".ToCharArray()); // -- FORMAT chunk bwOutput.Write("fmt ".ToCharArray()); // Length Of FORMAT Chunk (Binary, always 0x10) bwOutput.Write((uint)0x10); // Always 0x01 bwOutput.Write((ushort)0x01); // -- DATA chunk bwOutput.Write("data".ToCharArray()); // Length Of Data To Follow bwOutput.Write((uint)aud.Length); // Raw PCM data follows... // Reset position in aud and remember its origin position // to restore at the end. long originalaudStreamPosition = aud.Position; aud.Seek(0, SeekOrigin.Begin); // Append all data from aud stream into output stream. byte[] buffer = new byte[4096]; int read; // number of bytes read in one iteration while ((read = aud.Read(buffer, 0, 4096)) > 0) { bwOutput.Write(buffer, 0, read); } aud.Seek(originalaudStreamPosition, SeekOrigin.Begin); // ServiceSoapClient sr = new ServiceSoapClient(); sr.SavePcmToWavAsync(buffer);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 [WebService(Namespace = "http://tempuri.org/")] [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 Service () { } [WebMethod ] public void HelloWorld(string jj) { FileStream output = new FileStream("d:/kk.wav", FileMode.Create); } [WebMethod] public void SavePcmToWav(byte[] buffer) { // string saveTo = @"d:\kkk"; // // create a write stream // Stream output = new FileStream("d:/kk.wav", FileMode.Create); FileStream output = File.Create(@"d:\toto.wav"); //Stream output = File.Create("d:/toto.wav"); BinaryWriter bwOutput = new BinaryWriter(output); bwOutput.Write(buffer, 0, 4096); output.Close(); // rawData.Seek(originalRawDataStreamPosition, SeekOrigin.Begin); } }
merci
Partager